我有以下查詢:計算列
SELECT
a.source,
TotalCount,
ActiveCount
FROM
(
SELECT COUNT(*) AS TotalCount, a.source
FROM internship a
GROUP BY a.source
) AS A
join
(
SELECT COUNT(*) AS ActiveCount, b.source
FROM internship b
WHERE b.int_lastdate > CURDATE() AND b.status LIKE 'Published'
GROUP BY b.source
) AS B
ON A.source = B.source
上面的查詢給了我這樣的結果:
我想補充另一列這將是「ExpiredCount = TotalCount - ActiveCount」
我該如何達到這個目標?
謝謝!這個查詢也適用於創建視圖。 – Rohit