You have a table where hours are stores as integers and you need to display it in weeks, days and hours
If you have the following table

CREATE TABLE #Hours (hours int)
INSERT INTO #Hours
SELECT 5 UNION ALL
SELECT 55 UNION ALL
SELECT 125 UNION ALL
SELECT 1225 UNION ALL
SELECT 555 UNION ALL
SELECT 721 UNION ALL
SELECT 719

 


The expected output is this

 

Hours

weeks

days

hours

5

0

0

5

55

0

2

7

125

0

5

5

1225

7

2

1

555

3

2

3

721

4

2

1

719

4

1

23

Big deal right? So here is the deal, can you generate this output with code that is as short as possible. You do not need to alias the columns.

The code that I have is 50 characters.


Posted by Denis Gobo, filed under Uncategorized. Date: April 14, 2008, 10:34 am | No Comments »


Search Engine Optimization and SEO Tools