Question
· Nov 7, 2017

How to turn GROUP BY into OVER(PARTITION BY

I am a newbie to Cache and we are using dBeaver product to query against Cache tables.
I have the following query which does a GROUP BY to aggregate the columns:

SELECT PtNumber,cpt4_OVR,CollDateODBC, COUNT(*)
FROM site.MGBILL_View 
  WHERE cpt4_OVR IN ('36415', '36416')
     --AND ChargeFlags = '0'
       AND CollDateODBC > DATEADD(DAY,-45,CURRENT_DATE)
  GROUP BY PtNumber,cpt4_OVR, CollDateODBC
  HAVING count(*) > 2

-This returns a count of 3 for each patient (aggregated)

But I need to display the actual 6 rows. I would typically do this by replacing the GROUP BY with an OVER(PARTITION BY statement but that is not working.

Discussion (2)0
Log in or sign up to continue