我寫了這個查詢,當我從下拉列表中選擇一年時,這個查詢給出了所有12個月中所有365天的明智數據。每月數據的sql查詢
SELECT
YEAR(Date) AS [Year]
, MONTH(Date) AS [Month]
, COUNT(*) AS [Total]
FROM EnquiryMaster
WHERE EnquiryOwner = '" + enqowner + "'
AND DATEPART(yyyy, Date) = '" + year + "'
AND orgid = '" + orgid + "'
GROUP BY
YEAR(Date)
, MONTH(Date)
UNION ALL
SELECT
YEAR(Date) AS [Year]
, NULL
, COUNT(*)
FROM EnquiryMaster
WHERE EnquiryOwner = '" + enqowner + "'
AND DATEPART(yyyy, Date) = '" + year + "'
AND orgid = '" + orgid + "'
GROUP BY YEAR(Date)
我想寫一個查詢,將只用於每月
哪些數據您用於列日期的類型? – Ahmed