473,387 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Sum Union --Trying to Sum a Column

This is the query. I am trying to sum up the amt allowed. What is happening rite now is it stays separate. Any help would be appreciated!


SELECT SUM(AMT_ALLOWED) allowed, SUM(UNITS_NOT_DENIED) units, SUM(case when proc_modifier<>'26' then units_not_denied else 0 end) encounters, SERVICE_DATE.QUARTER
FROM ALL_CLAIMS, SERVICE_DATE, Provider
WHERE DATE_OF_SERVICE = DATE
AND DATE_OF_SERVICE BETWEEN '20060101' AND '20060630'
AND ALL_CLAIMS.denied_flag = 'N'
AND ALL_CLAIMS.last_version_flag = 'Y'
AND ALL_CLAIMS.PROVIDER_CAT <> '02'
AND ALL_CLAIMS.BUSINESS_LINE_KEY IN ('0001','0002','0003','0013','0032','0080','0081', '0093')
AND (all_claims.tos_code IN ('115','112','184')
OR all_claims.procedure_code BETWEEN 'C0078460' AND 'C0078496'
OR all_claims.procedure_code IN ('C0078890','C0078990'))
AND TAHP_POS_CODE NOT In ('01','13','08')
AND ALL_CLAIMS.PROVIDER_ID = Provider.PROVIDER_ID
AND ALL_CLAIMS.IPA IN ('02','04','05','10','17','29','48','52','55','64' ,'79','P2','P3','P6','P7','P8','P9','Q0','Q1','Q2' ,'Q3')
GROUP BY SERVICE_DATE.QUARTER

UNION
SELECT SUM(SPP_AMOUNT) allowed, SUM(UNITS_NOT_DENIED) units, SUM(case when proc_modifier<>'26' then units_not_denied else 0 end) encounters, SERVICE_DATE.QUARTER
FROM ALL_CLAIMS_AND_RISK_SPP, SERVICE_DATE, Provider
WHERE DATE_OF_SERVICE = DATE
AND DATE_OF_SERVICE BETWEEN '20060101' AND '20060630'
AND ALL_CLAIMS_AND_RISK_SPP.denied_flag = 'N'
AND ALL_CLAIMS_AND_RISK_SPP.last_version_flag = 'Y'
AND ALL_CLAIMS_AND_RISK_SPP.PROVIDER_CAT <> '02'
AND ALL_CLAIMS_AND_RISK_SPP.BUSINESS_LINE_KEY IN ('0001','0002','0003','0013','0032','0080','0081', '0093')
AND (ALL_CLAIMS_AND_RISK_SPP.tos_code IN ('115','112','184')
OR ALL_CLAIMS_AND_RISK_SPP.procedure_code BETWEEN 'C0078460' AND 'C0078496'
OR ALL_CLAIMS_AND_RISK_SPP.procedure_code IN ('C0078890','C0078990'))
AND TAHP_POS_CODE NOT In ('01','13','08')
AND ALL_CLAIMS_AND_RISK_SPP.PROVIDER_ID = Provider.PROVIDER_ID
AND ALL_CLAIMS_AND_RISK_SPP.IPA IN ('02','04','05','10','17','29','48','52','55','64' ,'79','P2','P3','P6','P7','P8','P9','Q0','Q1','Q2' ,'Q3')
GROUP BY SERVICE_DATE.QUARTER
Sep 15 '06 #1
0 2696

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

Similar topics

9
by: (Pete Cresswell) | last post by:
I've got some SQL that works as far as returning a recordset from a series of UNION statements. viz: SELECT whatever UNION this UNION that UNION other
2
by: d2r2 | last post by:
Hi, I'm trying to run a nested (UNION) query against a MSAccessXP database (version 2002; build 10.6501.6714; SP3) In Access the SQL-statement executes just fine. When I run it in a asp-page I...
3
by: Paradigm | last post by:
I am using Access 2K as a front end to a MYSQL database. I am trying to run a Union query on the MYSQL database. The query is (much simplified) SELECT as ID from faxdata UNION SELECT as ID ...
6
by: atefshehata | last post by:
hi all, i'm new to db2 and i have a simple question .. Using db2 ver 7. i have a table named 'Locations' with three varchar columns LocId,LocDesc,LocType when i execute >
14
by: Salad | last post by:
A97. Situation: I have 3 tables with a text field in each and a date field in the first 2 tables: Table1 Text1, Date1 Table2 Text2, Date2 Table3 Text3 (no date field) The following...
2
by: Lyn | last post by:
Hi, How do you bind the output columns from a UNION query when the fields from the two tables have different names? Consider this query (WHERE clauses omitted)... SELECT SurnameBirth,...
3
by: google | last post by:
This is something I've done plenty of times in '97, but I can't seem to get it to work correctly in Access 2003. Say, for example, I have a form with an unbound combobox, the data source is a...
5
by: Andy Kent | last post by:
What's the syntax for combining INTO and UNION clauses? What I want to do is: SELECT blah INTO newtable FROM oldtable1 WHERE <conditions> UNION SELECT blah
0
by: harrylarenson | last post by:
Hi, Happy New Year. I am trying to insert a query to a partitioned view but the error is : Server: Msg 4436, Level 16, State 12, Line 1 UNION ALL view 'T' is not updatable because a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.