1
假設我有這樣一個查詢作爲在SQL中,如何計算UNION的結果?
SELECT * from frequency where (...)
UNION
SELECT * from frequency where (...)
我怎麼能算多少結果從上面返回?
假設我有這樣一個查詢作爲在SQL中,如何計算UNION的結果?
SELECT * from frequency where (...)
UNION
SELECT * from frequency where (...)
我怎麼能算多少結果從上面返回?
使用COUNT()
功能與子查詢
SELECT COUNT(*) AS Row_Counts
FROM
(
SELECT * from frequency where (...)
UNION
SELECT * from frequency where (...)
) A
爲什麼UNION
?如果結合WHERE
條款,你可以得到數是這樣的:
SELECT COUNT(*)
FROM frequency
WHERE (...) OR (...)
是,要簡單得多,但應注意的是,這將只與UNION而不是UNION ALL工作... – Ben