我需要一些帮助来处理我的查询。
目前我正在返回一个结果列表,其中包括ID,Amount和SalesID。
我的输出示例如下:
ID: 41008 - SID: 492471 - Amount: 2000
ID: 46705 - SID: 492611 - Amount: 2000
ID: 46705 - SID: 494131 - Amount: 2000
ID: 46705 - SID: 494282 - Amount: 0
ID: 52178 - SID: 489954 - Amount: 5000
ID: 52617 - SID: 493990 - Amount: 2000
ID: 52617 - SID: 494288 - Amount: 0
ID: 54912 - SID: 492579 - Amount: 2000
ID: 57742 - SID: 492892 - Amount: 2000
ID: 58472 - SID: 492685 - Amount: 2000
ID: 58900 - SID: 492720 - Amount: 2000
ID: 59892 - SID: 489873 - Amount: 5000
当金额为0时,我想省略具有相同ID的记录。
目前我的SQL看起来像这样:
"SELECT * FROM sales WHERE Amount BETWEEN '"&dateBack&"' AND '"&dateForward&"'"
非常感谢任何帮助。
答案 0 :(得分:4)
"SELECT * FROM sales WHERE Paid BETWEEN '" & dateBack & "' AND '" & dateForward & "' " & _
"AND ID NOT IN " & _
"(SELECT ID FROM sales WHERE Amount = 0)"
答案 1 :(得分:1)
希望这有帮助
SELECT * FROM sales
WHERE Amount BETWEEN '"&dateBack&"'
AND '"&dateForward&"'"
AND Amount <> 0
我认为列名称被称为“付费”而不是“金额”
如果您需要什么,请告诉我。
答案 2 :(得分:1)
SELECT *
FROM sales
WHERE amount BETWEEN '"&dateBack&"'
AND '"&dateForward&"'
AND Amount <> 0
试试这个。添加新条件后,我们可以删除此" Amount <> 0 "
答案 3 :(得分:0)
试试这个:
SELECT * FROM sales
WHERE Amount BETWEEN "&dateBack&" AND "&dateForward&""
删除'
并尝试。