这是我的表格如下:
id | Prs Id | Amount | Status | Item Id| ---------------------------------------- 1 | 10 | 200 |pending | 5 | 2 | 10 | 300 |pending | 7 | 3 | 10 | 400 |pending | 9 | 4 | 10 | 100 |received| 6 | 5 | 10 | 200 |received| 8 | 6 | 10 | 300 |received| 3 | 7 | 10 | 200 |pending | 5 | 8 | 10 | 300 |pending | 7 | 9 | 10 | 400 |pending | 9 | 10 | 10 | 100 |received| 6 | 11 | 10 | 200 |received| 8 | 12 | 10 | 300 |received| 3 |
如何从amount
item_id
status
的特定pending
获得总和{{1}}?
答案 0 :(得分:4)
以下是对此的查询:
select sum(Amount)
from TableName
where Status = 'pending'
and Item_ID = 7