Page 1 of 1
Query question
Posted: Mon Jan 26, 2009 2:22 pm
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
Re: Query question
Posted: Mon Jan 26, 2009 9:57 pm
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
Re: Query question
Posted: Tue Jan 27, 2009 8:01 am
by fishdrzig
Nathan
Could you please test that query and let us know. Much appreciated. Thanks
Re: Query question
Posted: Thu Jan 29, 2009 5:34 am
by klinlv
The query in this form doesn't work for me. I copied and pasted it any suggestions.
Re: Query question
Posted: Thu Jan 29, 2009 10:34 pm
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