[SQL]Summing a column while ignoring duplicate records(row_number())


SELECT custid, SUM(amount)
FROM (SELECT t.*,
             ROW_NUMBER() OVER (PARTITION BY custid, transid ORDER BY transid) AS seqnum
      FROM table_1 t
     ) t
WHERE seqnum = 1;
#SQL






你可能感興趣的文章

MTR04_0715

MTR04_0715

[ 筆記 ] JavaScript 進階 07 - Prototype Chain

[ 筆記 ] JavaScript 進階 07 - Prototype Chain

Notification

Notification






留言討論