如果您使用的是 SQL Server,那么您可以将值转换为varchar
带有去除时间的格式:
SELECT convert(char(10), Jobs.DateCompleted, 120) AS DateCompleted,
SUM(Metrics.GB) AS GB,
SUM(Metrics.KB) AS KB
FROM Metrics
INNER JOIN Jobs
ON Jobs.JobId = Metrics.JobId
INNER JOIN Projects
ON Projects.ProjectId = Jobs.ProjectId
INNER JOIN JobTypes
ON JobTypes.JobTypeId = Jobs.JobTypeId
WHERE Jobs.DateCompleted Between '12/01/2012' AND '12/03/2012'
GROUP BY convert(char(10), Jobs.DateCompleted, 120)
如果您使用的是 SQL Server 2008+,则可以将该值转换为日期:
SELECT cast(Jobs.DateCompleted as date) AS DateCompleted,
SUM(Metrics.GB) AS GB,
SUM(Metrics.KB) AS KB
FROM Metrics
INNER JOIN Jobs
ON Jobs.JobId = Metrics.JobId
INNER JOIN Projects
ON Projects.ProjectId = Jobs.ProjectId
INNER JOIN JobTypes
ON JobTypes.JobTypeId = Jobs.JobTypeId
WHERE Jobs.DateCompleted Between '12/01/2012' AND '12/03/2012'
GROUP BY cast(Jobs.DateCompleted as date)
注意:我假设 SQL Server 基于您以前的标签