SELECT (res.phone_number_count + res.computer_count) AS user_count FROM (
SELECT COUNT(DISTINCT phone_number_id) AS phone_number_count, COUNT(DISTINCT computer_id) AS computer_count
FROM opinions
WHERE case_id = 1
) AS res;
我想要計算唯一的phone_number_ids和computer_ids。有沒有更好的方法來編寫這個特定的查詢?
關於改善你寫代碼和問題上的作品屬於codereview.stackexchange.com感謝 – dasblinkenlight 2013-04-27 17:11:08
。沒有意識到。 – Waffles 2013-04-27 17:51:26