Query question
Query question
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
-
- Posts: 172
- Joined: Mon Aug 04, 2008 12:39 pm
Re: Query question
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
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
Nathan
Could you please test that query and let us know. Much appreciated. Thanks
Could you please test that query and let us know. Much appreciated. Thanks
Re: Query question
The query in this form doesn't work for me. I copied and pasted it any suggestions.
-
- Posts: 172
- Joined: Mon Aug 04, 2008 12:39 pm
Re: Query question
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
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