Query question

For users or potential users.
Post Reply
fishdrzig
Posts: 433
Joined: Tue Oct 07, 2008 12:46 pm

Query question

Post by fishdrzig »

Is there a query I could run to print the year end ledger for a family that has been requesting one from me? They just need a list of the payments made, not 8 pages of statements and appointments. Thanks
nathansparks
Posts: 172
Joined: Mon Aug 04, 2008 12:39 pm

Re: Query question

Post by nathansparks »

Yeah, though a statement from the last year is the only way to show the context of the payments, otherwise it is not a ledger.

something like

SET @StartDate='2008-01-24';
SET @EndDate='2009-01-24';
SET @PatientNumber=1223;
SELECT p.Patnum, DatePay, SplitAmt FROM patient p INNER JOIN paysplit ps ON p.PatNum=ps.PatNum WHERE
DatePay BetWEEN @StartDate AND EndDate AND
p.Guarantor=@PatientNumber;

Make sure to use the gurantors patient number, I did not test this so it may have typos, will check tomorrow
nate
fishdrzig
Posts: 433
Joined: Tue Oct 07, 2008 12:46 pm

Re: Query question

Post by fishdrzig »

Nathan

Could you please test that query and let us know. Much appreciated. Thanks
klinlv
Posts: 55
Joined: Tue Jun 26, 2007 6:49 am

Re: Query question

Post by klinlv »

The query in this form doesn't work for me. I copied and pasted it any suggestions.
nathansparks
Posts: 172
Joined: Mon Aug 04, 2008 12:39 pm

Re: Query question

Post by nathansparks »

Yeah, sorry, got distracted.
It was missing an @ sign on a variable

try this

SET @StartDate='2008-01-24', @EndDate='2009-01-24',@GuarantorNumber=1223;
SELECT p.PatNum, ps.DatePay, ps.SplitAmt FROM patient p INNER JOIN paysplit ps ON p.PatNum=ps.PatNum WHERE
DatePay BETWEEN @StartDate AND @EndDate AND
p.Guarantor=@GuarantorNumber;

You can add any fields you like from either table in the area right after the SELECT statement.

Nathan
Post Reply