I am trying to create a query that has a bunch of billing information in it. Everything is billed monthly. They want a column that calculates the count of days of the week only in each month. Does anyone know how to do this?
SELECT count(weekday?), (p.serv_mo_dt, count(distinct c.Pgm_Clnt_ID) as Client_Count, c.site_id As SiteID, b.brd_nm,
avg(unit_billed_qy) as Avg_units, avg(ccms_line_am) as Avg_Amount_paid
FROM VCCS_CLIENT c INNER JOIN
VCCS_Paid_claim p ON c.Pgm_Clnt_ID = p.Pgm_Clnt_ID AND c.Site_ID = p.Site_ID, vccs_site_brd_xref b
WHERE (c.Pgm_Clnt_Katrina = '1' or c.Pgm_Clnt_Rita = '1') and p.inactv_fl = '0' and p.serv_mo_dt > = '9/1/2005'
and b.site_id = c.site_id
and c.inactv_fl = '0' and fund_cd BETWEEN '700' and '799'
group by p.serv_mo_dt, c.site_id, b.brd_nm
I would use a calendar table:
http://groups.google.de/group/microsoft.public.sqlserver.programming/browse_frm/thread/948d50fc4b94699
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
No comments:
Post a Comment