Actually it can be also written as
Select
name
, product
, date_of_sell
From
YOUR_TABLE
QUALIFY rank() Over (Partition By name, product Order By date_of_sell) <= 3
;
how about something like this
SELECT T.STOREID, T.DEALERCD, T.DEALERNAME, T.DEALERPERMIT
,SUM(CASE WHEN T.PREVDEALERCD IS NULL OR T.PREVDEALERCD <> T.DEALERCD THEN 1 ELSE 0 END) OVER(PARTITION BY STOREID)
FROM
(
SELECT S.STOREID, S.DEALERCD, S.DEALERNAME, S.DEALERPERMIT
,MAX(DEALERCD)...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.