Forum Discussion
kmdavisjr
Jun 23, 2021Copper Contributor
Tricky where clause
I have a very simple two attribute (User_integration_ID and Pick) relation and from this relation I am trying to select ONLY those attributes where the pick value is <=2 but if a particular user_inte...
kmdavisjr
Jun 24, 2021Copper Contributor
I figured it out.
SELECT DISTINCT
USER_INTEGRATION_ID
FROM
(
SELECT
USER_INTEGRATION_ID
,PICK
,MIN(PICK) OVER(PARTITION BY USER_INTEGRATION_ID) AS MINPICK
,MAX(PICK) OVER(PARTITION BY USER_INTEGRATION_ID) AS MAXPPICK
FROM
STUPID)
AS q
WHERE
MINPICK<=2 AND
MAXPPICK<=2
...Seems to work fine.