Hello
Is it some way to combine COUNT(*) and ROW_NUMBER on the same partition ?
For now I'm using a query like this
WITH Glob AS (SELECT p.ITEMID,
p.AffiliateID,
ROW_NUMBER() OVER(PARTITION BY p.itemid ORDER BY p.processingdate) AS rk,
COUNT(*) OVER(PARTITION BY p.itemid ) AS qty
FROM ItemProcessing p
)
SELECT
Itemid,
AffiliateID,
Qty
from Glob where rk=1
But I can imagine that it will be more efficient to use the same partition to get both rk and Qty ?
Is there a more effective way