我写了这个查询,当我从下拉列表中选择一年时,它给出了所有 12 个月的所有 365 天的每日数据。
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)
我想编写一个查询,该查询还将选择月份和年份并仅显示该月份的数据