hansdebadde
Technical User
I am using SQL 2008 and am new to it. I want to group a table tbl_hrs which has two fields:
dtm_tcdate and int_hrs
However i want to group by financial periods (13 per yr). I was thinking the easiest long term solution would be to create another table: tbl_fincanceperiods that held these dates (dtm_financeperiod) and then group the other table by these values. However some of the dtm_tcdates don't equal the dtm_financeperiod but are between them. For example if the dates for dtm_financeperiod were January 1, 2012 and January 15, 2012 but the dtm_tcdate was January 5, 2012 i would want it in the January 1,2012 group and have its int_hrs summed with all the other values for that group.
How would I go about writing this query so it can be grouped as such and the hrs summed? I hope this makes sense. Thanks in advance
dtm_tcdate and int_hrs
However i want to group by financial periods (13 per yr). I was thinking the easiest long term solution would be to create another table: tbl_fincanceperiods that held these dates (dtm_financeperiod) and then group the other table by these values. However some of the dtm_tcdates don't equal the dtm_financeperiod but are between them. For example if the dates for dtm_financeperiod were January 1, 2012 and January 15, 2012 but the dtm_tcdate was January 5, 2012 i would want it in the January 1,2012 group and have its int_hrs summed with all the other values for that group.
How would I go about writing this query so it can be grouped as such and the hrs summed? I hope this makes sense. Thanks in advance