嗨,我想从 Sql Server 表中检索具有最小值但不应更改行中数据顺序的行,即不应将 Id 旁边的数据排序错误我正在尝试获取结果,但我不是对我得到的结果感到满意。我知道我可以使用 where 子句来阻止数据放错顺序,但是因为我想将它与 java 向量相关联,所以我不能使用该选项。这是我目前正在编码的内容 rm_id 是我的 ID,但我到处都是最小值,即 0
SELECT b.rm_id AS 'REMITTANCE ID',
min(b.[1]) AS 'Re. 1',
min(b.[2]) AS 'Rs. 2',
min(b.[5]) AS 'Rs. 5',
min(b.[10]) AS 'Rs. 10',
min(b.[20]) AS 'Rs. 20',
min(b.[50]) AS 'Rs. 50',
min(b.[100]) AS 'Rs. 100',
min(b.[500]) AS 'Rs. 500',
min(b.[1000]) AS 'Rs. 1000',
min(b.[tp]) AS 'T.P',
min(b.[tv]) AS 'T.V'
FROM trans_det AS b
GROUP BY b.rm_id WITH ROLLUP
ORDER BY rm_id DESC;