sql server - Sql data sorted by calendar date -
sql server - Sql data sorted by calendar date -
sql info sorted weekly calendar days..ex feb 1, 2013 friday, in need pull in info feb 1 & 2. right pulls info entire week of 1-27-2013 2-2-2013. results set in total billed week end dates. ex( 1-5-13, 1-12-13) end of jan , origin of feburary need results 1-27-13 1-31-13 = "total" week ending date 31st. febuary 2-1-13 2-2-13 = "total"
i have been able individual days, thats not how "accounting" wants it.
thanks in advance. here code:
select dateadd(week, datediff(wk, 0, bd.[service date 1]) ,5) month, bd.chart, bd.[transaction code], sum(bd.units) [total billed] dbo.[billing detail] bd inner bring together dbo.patient p on bd.chart = p.[chart number] (bd.[transaction code] = 'h2016') , (bd.[service date 1] >= '01/01/2013') , (bd.[service date 1] < '12/31/2013') grouping dateadd(week, datediff(wk, 0, bd.[service date 1]) ,5), bd.chart, bd.[transaction code] order bd.chart
just add together select list (and grouping list) 2 fields:
... month([service date 1]), datepart(week,[service date 1]) ...
and should it
sql sql-server sql-server-2008
Comments
Post a Comment