在MySQL中选择sum,但带where



我正在尝试汇总orders表的total_grand列。

所以我有这个查询

SELECT sum(total_grand) as total 
FROM `orders` 
WHERE overall_status in ("In-Transit","Not Yet Shipped","Not Yet Validated");

它运行良好。但我需要添加新的条件语句。

这是我的带有数据的示例orders表列。

1<1><1>
total_grandoverall_statustelevifier_user_id
100在途
200尚未发货
300尚未验证NULL
400尚未验证
500In-td>1
------------------------------------------------------
SELECT sum(total_grand) as total 
FROM `orders` 
WHERE overall_status in ("In-Transit", "Not Yet Shipped", "Not Yet Validated") 
AND televalidator_user_id is not null;

最新更新