我想同时查询多个选择,我的查询在没有最后一个 SELECT 的情况下工作,但是我有一个错误,Operand should contain 1 column
有人可以告诉我如何更正吗?
SELECT (
SELECT COUNT(*) FROM mytable WHERE TYPE = 'MSS' AND YEAR(date) = YEAR(CURDATE()) AND MONTH(date) = MONTH(CURDATE())
) as TOTAL_MSS,
(
SELECT COUNT(*) FROM mytable WHERE TYPE = 'MSS' AND S = 0 AND YEAR(date) = YEAR(CURDATE()) AND MONTH(date) = MONTH(CURDATE())
) as MSS_S,
(
SELECT COUNT(*) FROM mytable WHERE TYPE = 'MSS' AND S != 0 AND YEAR(date) = YEAR(CURDATE()) AND MONTH(date) = MONTH(CURDATE())
) as MSS_F,
(
SELECT COUNT(*) as Nb ,OR as TOP FROM mytable WHERE TYPE = 'MSS' AND YEAR(date) = YEAR(CURDATE()) AND MONTH(date) = MONTH(CURDATE()) GROUP BY OR ORDER BY Nb DESC LIMIT 1
)
如果我分别执行它们,我会得到
TOTAL_MSS MSS_S MSS_F
99 12 87
Nb TOP
78 j.r@domain.com