View Single Post

   
  #1 (permalink)  
Old 02-27-2008, 05:44 AM
Hemant Shah
 
Posts: n/a
Default Grouping data by week?


Folks,

We have table that cointains timesheet entries for the employees.

Given user name, start date, and end date I want to get sum of hours for
each project, for each week.

Exmaple: Table looks like

UserName, Date, Project, Hours.

Suppose input is: shah, 2005-12-01, 2005-12-07.

2005-12-01 is on Thursday so I want to start from Sunday 2005-11-27,
2005-12-07 is on Wednesday so I want to end on Saturday 2005-12-10.

The output should look like:

Week of 2005-11-27

ProjectA 12
ProjectB 5
ProjectC 20


Week of 2005-12-04

ProjectA 21
ProjectB 15
ProjectC 0


Is there a DB2 function that will give me first day of week?
How can I group the sum of hours of the project by week?


Thanks.


--
Hemant Shah /"\ ASCII ribbon campaign
E-mail: NoJunkMailshah@xnet.com \ / ---------------------
X against HTML mail
TO REPLY, REMOVE NoJunkMail / \ and postings
FROM MY E-MAIL ADDRESS.
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind, Above opinions are mine only.
it's backed up on tape somewhere. Others can have their own.
Reply With Quote