I am trying to identify claims that meet the following criteria:
- Each line must have denial code "X"
- One line must have an allowed amount that is greater than $0.00
- The remaining lines must have an allowed amount equal to $0.00
Example: Claim ID 123456 has three rows associated with this ID. Row 1 allowed $40.00. Rows 2 and 3 allowed $0.00. With this query Claim ID 123456 would pull.
The only way I can think of doing this is running a query for all claims that have denial code "X" and then manually searching in Excel.
Basically the query I have is:
SELECT DISTINCT
Claim ID,
Line Number,
Denial Code,
Line Allowed Amount
(FROM)
WHERE
Denial Code = 'X'
This sounds like aggregation and filtering with a
havingclause: