我有這個疑問得到的PlayerSession
s的reconnect = TRUE
數量,由Player.country
分組:計數行與聚集查詢特定條件
SELECT
country,
COUNT(*) AS with_reconnect
FROM PlayerSession S LEFT JOIN Player P ON (P.id = S.player_id)
WHERE reconnect = TRUE
GROUP BY country
我想修改它顯示不只是重新連接會議計數,但也是總數,如:
SELECT
country,
COUNT(*) AS total,
(COUNT WHERE reconnect = TRUE) AS with_reconnect
FROM PlayerSession S LEFT JOIN Player P ON (P.id = S.player_id)
GROUP BY country
這是可能的,如果是這樣,什麼是正確的語法?
見http://stackoverflow.com/questions/4414539/easiest-way-to-get- a-total-count-and-a-subset-of-subset – kaj 2012-02-22 12:36:35