我的表“事务”有以下列:
我运行了下面的查询并获得了一些输出,但是由于我没有me.Therefore的预期输出,我希望有人帮助我确认这段代码是否总是工作的,如果没有,建议编辑。
select cust_id, COUNT(cust_id) AS Count_of_Transactions
from Transactions
where Qty >= 0
group by cust_id
having COUNT(cust_id) > 10我没有预期的产量。
谢谢!
发布于 2019-08-27 14:08:30
没有看到预期的产出,我认为你所拥有的是正确的。如果您想要查看总计的总和,只需在查询中再添加一列:
SELECT cust_id,
SUM(total_amt) AS Total_Amount_of_Transactions,
COUNT(cust_id) AS Count_of_Transactions
FROM Transactions
WHERE Qty >= 0
GROUP BY cust_id
HAVING COUNT(cust_id) > 10https://stackoverflow.com/questions/57676419
复制相似问题