I need a query that would yield all services provided for August and
September grouped by the effected insurance carriers. It would be
helpful if the services listed within each carrier group were in
ascending order by service code.
SELECT DISTINCT c.payorname, a.srvcode, a.lastname, a.firstname, a.id, a.trandate,d.insdid,d.insgroup, a.provcode, a.amount FROM sos.rv_charges a JOIN sos.ptpayors b ON a.ptpayornum = b.ptpayornum JOIN sos.ptpolicies d ON b.ptpayornum = d.ptpayornum JOIN sos.payors c ON b.payornum = c.payornum WHERE trandate BETWEEN '2008-08-01' AND '2008-09-30' /* replace with appropriate payor numbers in line below */ AND c.payornum IN (122,25626,9750,178,8807,120,8439,25627,25584,25585) ORDER BY c.payorname, a.srvcode, a.lastname, a.firstname, a.id, a.trandate