Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Add multiple datesofservice to one row

Author  Topic 

tmeans11
Starting Member

3 Posts

Posted - 2009-01-27 : 21:53:18
Hello, Thanks so much for helping me with my other query!

I have a question about a different query. Below is what I have so far.
__________________________________________________________
Query -
select pp.patientid, ins.name, ins.contact, ins.address1, ins.address2, ins.city, ins.state,
ins.zip, pp.last, pp.first, pi.insuredid, pv.ticketnumber, pi.last, pi.first, pvp.dateofservicefrom, pvp.fee

from patientprofile pp
inner join patientinsurance pi on pp.patientprofileid = pi.patientprofileid
inner join insurancecarriers ins on pi.insurancecarriersid = ins.insurancecarriersid
inner join patientvisit pv on pp.patientprofileid = pv.patientprofileid
inner join patientvisitagg pva on pv.patientvisitid = pva.patientvisitid
inner join patientvisitprocs pvp on pv.patientvisitid = pvp.patientvisitid

where pv.lastfileddate >= '2008-01-01' and pv.lastfileddate < '2008-02-28'
AND pva.insbalance > $50.00

group by pp.patientid, ins.name, ins.contact, ins.address1, ins.address2, ins.city, ins.state,
ins.zip, pp.last, pp.first, pi.insuredid, pv.ticketnumber, pi.last, pi.first, pvp.dateofservicefrom, pvp.fee
___________________________________________________________
Results -
Patientid Insurance Name Conact Add1
347922 Health Plan of Michigan NULL- 777 Woodward Ave

Add2 City St zip Ptlast Pt first PolicyNum Ticknum
Suite600 Detroit MI 48226 Duck Donald 65555400 6957

Inslast InsFirst DateofService Total Fee
NULL NULL 12/5/07 12:00 AM $415.00



in my results I need the file to show one row per insurance company, ticketnumber - Then show all Dates of Service per ticketnumber on one row. So the end of the file would look like this...
DateofService1 Fee1 DateofService2 Fee2 DateofService3 Fee3.

If I wanted one row with several datesofservice how would I change my query above?

Hopefully this can be understood. Can anyone help??? Thanks much...
   

- Advertisement -