求一个sql语句。查询出来每一天的产生数据的条数。

求一个sql语句。查询出来每一天的产生数据的条数。,第1张

是这样的,首先你需要在表A中创建一个“时间”列,假设我们取名为“time”,然后我们将js传入的时间段命名为“timeStart”及“timeEnd”,然后sql语句就可以写出来啦:
select count() from A where time between timeStart and timeEnd

举例如下:
select

from
timetable
where
datediff(mi,'2008-10-10
8:00:00',timet)>=1
and
datediff
(mi,'2008-10-10
9:00:00',timet)<=30

select  from 表名 where substring(deliveryDate,14,2)>='08' and substring(deliveryDate,14,2)<'18' and substring(deliveryDate,7,1)='7' and substring(deliveryDate,10,2)!='31' --后面的substring(deliveryDate,7,1)='7'限制的是7月份的数据,7月有31天 添加条件substring(deliveryDate,10,2)!='31'(如果字段deliveryDate中没有空格的话就是上面的额,如果年月日和时间中有空格的话,稍微调整一下数字就可以了)

SELECT
时间,
AVG(体温)
FROM

WHERE
时间>起始时间
and
时间
<截至时间
AND
姓名
in
('李四','张三')
GROUP
BY
时间
ORDER
BY
时间
其中
姓名
in
('李四','张三')
对于复杂的筛选
可以用姓名
in
(select
姓名
from

where
删选条件)
来实现


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/13353190.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-07-20
下一篇 2023-07-20

发表评论

登录后才能评论

评论列表(0条)

保存