我试图获取一个表上的每小时数据,该表在mysql上运行正常但在sql上运行不正常。如何在sql server managmenmt studio中使用它,我收到' time'不是公认的函数名称。而curdate()不识别函数。
select [pa_number], [pa_surname]
,[pa_forename],
sum(time(datetime) >= '07:00:00' and time(datetime) < '08:00:00') as '7.00-8.00 AM',
sum(time(datetime) >= '08:00:00' and time(datetime) < '09:00:00') as '8.00-9.00 AM',
sum(time(datetime) >= '09:00:00' and time(datetime) < '10:00:00') as '9.00-10.00 AM ',
sum(time(datetime) >= '10:00:00' and time(datetime) < '11:00:00') as '10.00-11.00 AM',
sum(time(datetime) >= '11:00:00' and time(datetime) < '12:00:00') as '11.00-12.00 AM',
sum(time(datetime) >= '12:00:00' and time(datetime) < '13:00:00') as '12.00-1.00 PM',
sum(time(datetime) >= '13:00:00' and time(datetime) < '14:00:00') as '1.00-2.00 PM',
sum(time(datetime) >= '14:00:00' and time(datetime) < '15:00:00') as '2.00-3.00 PM',
sum(time(datetime) >= '15:00:00' and time(datetime) < '16:00:00') as '3.00-4.00 PM',
sum(time(datetime) >= '16:00:00' and time(datetime) < '17:00:00') as '4.00-5.00 PM',
sum(time(datetime) >= '17:00:00' and time(datetime) < '18:00:00') as '5.00-6.00 PM',
sum(time(datetime) >= '18:00:00' and time(datetime) < '19:00:00') as '6.00-7.00 PM'
from [ICPS].[dbo].[parking_attendants] t
inner join tickets a
on t.[pa_number] = a.[t_pa_number]
where cast(t.DATETIME AS DATE) = CURDATE()
group by pa_surname