
sql 高分求助 关于时间段内所有数据 统计成一天一天的合
selecta.cartype,a.carid,a.license,a.tel,a.owner,isnull((selectmax(b.sdisup/1000)-min(...
select a.cartype, a.carid,a.license,a.tel,a.owner,
isnull((select max(b.sdisup/1000)-min(b.sdisup/1000) from autogpsinfo b
where a.tel=b.tel and b.gpsdatetime>='2009-05-01 12:06:45' and b.gpsdatetime<='2009-06-11 12:06:45'),0) as val
from carinfo a
inner join carterm t on t.groupname=a.term
where t.username='admin' and a.tel='13866880002'
如何能把这个sql统计的数据 分拆成一天一天的 实现后马上给分 速求 简单解释以下 这个是 车辆即时里程数的上报信息统计,里程一直在增加 上面的语句现在可以求到一个时间段内的某个车辆的 行驶里程数,现在需要把每天的里程列出来如何实现 可以给查找的数据加一个日期列 具体如何实现 如何修改上面的语句 展开
isnull((select max(b.sdisup/1000)-min(b.sdisup/1000) from autogpsinfo b
where a.tel=b.tel and b.gpsdatetime>='2009-05-01 12:06:45' and b.gpsdatetime<='2009-06-11 12:06:45'),0) as val
from carinfo a
inner join carterm t on t.groupname=a.term
where t.username='admin' and a.tel='13866880002'
如何能把这个sql统计的数据 分拆成一天一天的 实现后马上给分 速求 简单解释以下 这个是 车辆即时里程数的上报信息统计,里程一直在增加 上面的语句现在可以求到一个时间段内的某个车辆的 行驶里程数,现在需要把每天的里程列出来如何实现 可以给查找的数据加一个日期列 具体如何实现 如何修改上面的语句 展开
4个回答
2013-08-23
展开全部
d为日期,L为里程,你自己注意下日期格式。select left(max(d),10),max(l)-min(l)
from table1
group by left(d,10)
from table1
group by left(d,10)
2013-08-23
展开全部
最好给出表结构和你期望得到的数据的格式
这么一大段看不清
这么一大段看不清
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-08-23
展开全部
需要循环吗 ??单条SQL如何 实现啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-08-23
展开全部
你的数据表里面有日期字段吗?如果有的话,后面加上个 group by 就可以实现
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询