Sql4Cds
Sql4Cds copied to clipboard
Window functions
SELECT leadid, ROW_NUMBER() OVER (PARTITION BY parentaccountid ORDER BY createdon ASC) AS rownum
FROM lead
WHERE parentaccountid IS NOT NULL
SELECT leadid, ROW_NUMBER() OVER (PARTITION BY parentaccountid ORDER BY createdon ASC) AS rownum
FROM lead
WHERE parentaccountid IS NOT NULL