2018年3月12日 星期一
How to select top 1 record per group
抓取客戶最後一次購買此產品的日期
SELECT product, cus, date
FROM (
SELECT product,
cus,
date,
row_number() over (partition by product, cus order by date desc) as ranker
FROM SalesTable
) z
WHERE ranker = 1
訂閱:
文章 (Atom)