不止一次爲同一列:
SELECT count(pn1)
FROM pledges
WHERE date1 BETWEEN '2011-05-05' AND '2011-06-06'
OR date1 BETWEEN '2011-07-05' AND '2011-08-06'
兩個不同的列:
SELECT count(pn1)
FROM pledges
WHERE date1 BETWEEN '2011-05-05' AND '2011-06-06'
AND date2 BETWEEN '2011-05-05' AND '2011-06-06'
編輯:根據評論,也許您正在尋找這樣的事情呢?
SELECT SUM(CASE WHEN date1 BETWEEN '2011-05-05' AND '2011-06-06' THEN 1 ELSE 0) END AS Count1,
SUM(CASE WHEN date1 BETWEEN '2011-07-05' AND '2011-08-06' THEN 1 ELSE 0) END AS Count2
FROM pledges
WHERE date1 BETWEEN '2011-05-05' AND '2011-06-06'
OR date1 BETWEEN '2011-07-05' AND '2011-08-06'
不,我不是那個意思that..i希望看到兩個結果。在我的查詢我可以看到也查詢一個結果,但我想2個結果example..the當前查詢給我6作爲結果,我希望看到6和8作爲結果 – 2011-05-07 07:37:09
@ m.basleem:看看我編輯的答案是否符合您的需求。 – 2011-05-09 20:17:19
是的,這是我正在尋找..謝謝 – 2011-05-11 07:53:31