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
Comments
correct.
OVER(PARTITION BY
is an unknown keyword in documentation
You may need to reformulate your query to achieve a similar result
Looks like it's from MS SQL