Query 126 - Does pv.Abbr need to be here?

For complex topics that regular users would not be interested in. For power users and database administrators.
Post Reply
V Suite
Posts: 136
Joined: Sun Aug 19, 2007 6:56 pm

Query 126 - Does pv.Abbr need to be here?

Post by V Suite » Wed Dec 23, 2009 6:54 pm

Hygiene production sum - Query 126 - Does pv.Abbr need to be here? I don't think it is doing what it should be doing.

Code: Select all

SET @FromDate='2008-06-01' , @ToDate='2008-06-30';
SELECT Count(*),pv.Abbr, pc.ProcCode, pc.AbbrDesc, AVG(pl.ProcFee) as '$Ave. Fee' , SUM(pl.ProcFee) AS '$Tot. Prod' FROM patient 
INNER JOIN procedurelog  pl ON patient.PatNum=pl.PatNum
INNER JOIN procedurecode pc ON pl.CodeNum= pc.CodeNum
INNER JOIN provider pv ON pl.ProvNum=pv.ProvNum
WHERE pl.ProcStatus = '2' AND (pl.ProcDate >=@FromDate
AND pl.ProcDate <= @ToDate) AND pc.IsHygiene=1
GROUP BY pc.ProcCode
ORDER BY ProcCode;

V Suite
Posts: 136
Joined: Sun Aug 19, 2007 6:56 pm

Re: Hygiene Production Query 126 - Does pv.Abbr need to be here?

Post by V Suite » Tue Jan 05, 2010 5:20 pm

Does any one use this query?
If so, it does not appear that pv.Abbr works, could anyone advise me please, thanks.

User avatar
jordansparks
Site Admin
Posts: 5770
Joined: Sun Jun 17, 2007 3:59 pm
Location: Salem, Oregon
Contact:

Re: Query 126 - Does pv.Abbr need to be here?

Post by jordansparks » Tue Jan 05, 2010 7:59 pm

pv.Abbr just means the provider abbreviation. That column looks like it's working fine to me in the result. Is there something about the result that looks wrong to you?
Jordan Sparks, DMD
http://www.opendental.com

V Suite
Posts: 136
Joined: Sun Aug 19, 2007 6:56 pm

Re: Query 126 - Does pv.Abbr need to be here?

Post by V Suite » Thu Jan 07, 2010 5:40 am

To my understanding, the query should list each proc code, and each provider who performs that treatment code.
So,
100, #1, D1110 , Pro
189, #2, D1110, Pro
115, #3, D1110, Pro
25, #1, D1112, Pro2
12, #2, D1112, Pro2
7, #1, D1120, ProChild
9, #3, D1120, ProChild
etc

However it only lists one provider for each proc code, so it is not possible to tabulate the comparative performance.
404, #2, D1110, Pro
37, #1, D1112, Pro2
16, #3, D1120, ProChild

The numbers listed are the correct sums but the totals are ascribed to the provider with most of each procedure.

I just figured it out. To get the list separated by provider, simply change the second to last line to
GROUP BY pc.ProcCode, pv.ProvNum

Jordan, Please update Query #126 to remedy this.

Post Reply