473,499 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Comples Query to Include % of two columns calculation

1 New Member
I am building a query that gives the following information
Total Claims, Total Charges, Total Payment, Denial Count, % of Billed Charges and % of Claims Denied

This is all grouped by provider id, provider name and denied count then ordered by Total Claims.

I have been successful with my query until it comes to getting the % of Billed Charges and % OF Claims denied. You will see below my attempt to build a query in the select portion of the statement which of course did not work at all. When I -- the statement the query works so I know the mistake is specifically on that statement. I'm thinking it would as well need to be in one of the joins.....

I have no clue how to perform this type of aggregate. I need to have the % grouped by the provider as the count and sums are in the select statement and joins

Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2. P.PRPR_ID , 
  3. P.PRPR_NAME AS "Provider Name", 
  4. COUNT(C.CLCL_ID) AS "Total Claims",
  5. SUM (CL.CDML_CHG_AMT) AS "Total Charges",
  6. SUM (CL.CDML_PR_PYMT_AMT) AS "Total Payment",
  7. ISNULL(C2.Denied_Count,0) Denied_Count
  8. --(SUM(CL.CDML_PR_PYMT_AMT)/SUM(CL.CDML_CHG_AMT))FROM DW.FAC_CMC_CDML_CL_LINE CL AS "% of Billed Charges"
  9. FROM DW.FAC_CMC_CLCL_CLAIM C
  10. LEFT JOIN DW.FAC_CMC_PRPR_PROV P
  11. ON C.PRPR_ID = P.PRPR_ID
  12. LEFT JOIN DW.FAC_CMC_CDML_CL_LINE CL
  13. ON C.CLCL_ID = CL.CLCL_ID
  14. LEFT JOIN (SELECT P.PRPR_ID, COUNT (DISTINCT C.CLCL_ID) AS Denied_Count
  15. FROM DW.FAC_CMC_CLCL_CLAIM C 
  16. JOIN DW.FAC_CMC_PRPR_PROV P
  17. ON C.PRPR_ID = P.PRPR_ID
  18. WHERE C.CLCL_TOT_PAYABLE = '0.00'
  19. AND C.CLCL_LOW_SVC_DT >= '07/01/2015'
  20. AND C.PRPR_ID IN ('x', 'y', 'z')
  21. GROUP BY P.PRPR_ID
  22. ) c2 on C.PRPR_ID=c2.PRPR_ID
  23. WHERE C.CLCL_LOW_SVC_DT >= '07/01/2015'
  24. AND C.PRPR_ID IN ('x', 'y', 'z')
  25. AND C.CLCL_CUR_STS IN ('01', '02')
  26. GROUP BY 
  27. P.PRPR_ID , 
  28. P.PRPR_NAME, 
  29. C2.Denied_Count
  30.  
  31. ORDER BY [Total Claims] DESC
Oct 6 '15 #1
0 1551

Sign in to post your reply or Sign up for a free account.

Similar topics

5
276
by: Timur | last post by:
Hi gurus, I have a problem to convert MS SQL Server application to DB2. I have a view which combines 7 tables ( table sizes 60millions rows, 3 mill, 1 mill, other small ones) I use this view to...
3
2075
by: Jamie Pittman via AccessMonster.com | last post by:
I am having trouble bellow wit this query. I have the total regular hours and the overtime. The problem is that if it is 8 hours and under, I need it to show as regular hours. Any thoughts? ...
14
2444
by: Crimsonwingz | last post by:
Need to calculate a sum based on a number of factors over a period of years. I can use formula ^x for some of it, but need totals to carry over in the sum and have only been able to do this thus...
5
1416
by: MattPF | last post by:
I have a table that is -- 30 Megabytes 90,000 rows ~65 columns My query goes SELECT city FROM table WHERE zip = 90210; It will then find about 10 matching records.
6
4812
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
4
6918
by: anniebai | last post by:
I have a query named "Tuition Calculation" saved in the database. In the code, the criteria of the query need to be added/modified and be saved for use of another auto-generate report. Is...
1
2555
by: mfletcher | last post by:
Hi I have a query which calculates a large number of fields for each record, i don't want all of the fields present in the datasheet view only those fields selected by the user in a list box(or...
1
2908
by: Jmaes Wang | last post by:
Attached please find my code. I failed to query the blob column. Note the Paradox driver version is 4.0. The error is: Error code: -2146232009 Error msg: ERROR Too few parameters. Expected 1....
4
2720
by: Charles Ndethi | last post by:
Hi, I want to query the table below as to return the titles of the column where the intersection of SessionId and Roomx is 0.The type of the Room is TINYINT - which in mysql represents BOOLEAN ...
0
7128
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7385
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4917
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4597
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1425
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
294
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.