ORACLE查询总和组按显示最后一个ID

时间:2017-08-31 10:01:50

标签: oracle

我在桌面上有一个Oracle查询数量。

SELECT SEI_NO, SUM(T.QUANTITY) AS TOTAL
FROM WA_II_TBL_TR_EQUIPMENT T
WHERE T.SUPPLIERID_FK = '62551'
GROUP BY T.SEI_NO

但现在我想添加至少最后一个ID的列事务ID。

TR_ID | SEI_NO   | TOTAL
1     | SDGDFGSD | 2
2     | SDGDFGSD | 2
3     | SDGDFGSD1| 10

我想要展示的内容:

TR_ID | SEI_NO   | TOTAL
1     | SDGDFGSD | 4
3     | SDGDFGSD1| 10

有可能吗?

1 个答案:

答案 0 :(得分:1)

SELECT min(TR_ID) as  TR_ID,
    SEI_NO,
    SUM(T.QUANTITY) AS TOTAL
FROM   WA_II_TBL_TR_EQUIPMENT T
WHERE T.SUPPLIERID_FK = '62551'
GROUP BY T.SEI_NO

这应该是诡计。