假设我有一个查询,例如
SELECT * from frequency where (...)
UNION
SELECT * from frequency where (...)
如何计算从上面返回的结果数量?
答案 0 :(得分:5)
将COUNT()
函数与子查询一起使用
SELECT COUNT(*) AS Row_Counts
FROM
(
SELECT * from frequency where (...)
UNION
SELECT * from frequency where (...)
) A
答案 1 :(得分:1)
为什么UNION
?如果你结合WHERE
条款,你可以这样计算:
SELECT COUNT(*)
FROM frequency
WHERE (...) OR (...)