我想检索待处理查询的计数和每位顾问的已完成查询的计数,并显示在表格中。检索这些数据的SQL查询是什么?
SELECT CounsellorName,
(SELECT COUNT(Status)
FROM register WHERE Status='Pending') AS pending,
(SELECT COUNT(Status) FROM register WHERE Status='Completed') AS completed
FROM register
GROUP BY CounsellorName
我目前正在使用此功能,但它不会检索每位顾问的个人计数。
感谢您的支持!
答案 0 :(得分:0)
试试这个:
SELECT CounsellorName,
sum(Status='Pending') AS pending,
sum(Status='Completed') AS completed
FROM register
GROUP BY CounsellorName
它根据counsellorName查找待处理和已完成状态的计数。