如何獲得結果而無需分組?選擇不分組
我的表
id user_id amount currency_id type status
5 2 2.00 1 0 0
6 3 3.00 1 0 0
4 1 1.00 1 0 0
7 4 4.00 1 0 0
8 5 3.00 1 1 0
我做了以下選擇
SELECT id, user_id, amount, currency_id, SUM(amount)
FROM market
WHERE amount <=3
AND type = 0
AND status = 0
結果:
id user_id amount currency_id SUM(amount)
5 2 2.00 1 6.00
如何得到這樣的結果:
id user_id amount currency_id SUM(amount)
5 2 2.00 1 0 6.00
6 3 3.00 1 0 6.00
4 1 1.00 1 0 6.00
如果您不想使用GROUP,請不要使用SUM()。你是否試圖獲得查詢中所有記錄的總和?我想我沒有看到每行的'6.00'來自哪裏。 –