Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MS Access SQL代码检查_Sql_Ms Access - Fatal编程技术网

MS Access SQL代码检查

MS Access SQL代码检查,sql,ms-access,Sql,Ms Access,我正在编写一些SQL代码,但不精通MS Access,因此希望确保它的行为符合我的预期 我想做的是获得2015年6月1日至2016年5月31日期间一组记录的军事时间计数和小时数。我想知道我每小时有多少张唱片。记录发生在哪一天并不重要,只是时间 SELECT DatePart("h",[CentralTime]) AS Expr1, Count(DatePart("h",[CentralTime])) AS Expr2 FROM Master WHERE (((Master.CentralTime

我正在编写一些SQL代码,但不精通MS Access,因此希望确保它的行为符合我的预期

我想做的是获得2015年6月1日至2016年5月31日期间一组记录的军事时间计数和小时数。我想知道我每小时有多少张唱片。记录发生在哪一天并不重要,只是时间

SELECT DatePart("h",[CentralTime]) AS Expr1, Count(DatePart("h",[CentralTime])) AS Expr2
FROM Master
WHERE (((Master.CentralTime) Between #6/1/2015# And #5/31/2016#))
GROUP BY DatePart("h",[CentralTime]);

是的,您的查询很好,它将执行您希望它执行的操作。 我倾向于使用count('x'),您可能会丢失一些括号,但您的查询将按原样工作

或者使用以下命令:

SELECT DatePart("h",[CentralTime]) AS Expr1, Count('x') AS Expr2
FROM ShipandGetCalls_Master
WHERE ShipandGetCalls_Master.CentralTime Between #6/1/2015# And #5/31/2016#
GROUP BY DatePart("h",[CentralTime]);

您可能需要查看过滤器,了解是否要包含2016年5月31日的数据。您可以将此字段更改为日期/时间,以进一步准确指定要查询返回的内容。

感谢您的回复和建议。你说的过滤器是指如果我只想在2016年5月31日上午10点的话?