coolingpipe(冷箫轻笛)还要麻烦你:)

xhll2233 2006-12-29 07:10:43
insert into b
select top 1 datepart(hh,dateandtime) as dateandtime,
val1 = (select val from a where dateandtime = t1.dateandtime and tagindex = 1),
val3 = (select val from a where dateandtime = t1.dateandtime and tagindex = 3),
val4 = (select val from a where dateandtime = t1.dateandtime and tagindex = 4)
from a t1
--where datediff(hh,DateAndTime,getdate())=1
group by dateandtime
order by sum(val) desc
这个不是查找上一个小时的数据,我在数据库用这句查询的时候它在所有的数据里面查找
...全文
105 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
冷箫轻笛 2006-12-29
  • 打赏
  • 举报
回复
哦,楼主,那个where条件注释掉了阿!
要加上的

原来给出的测试数据因为不满足条件所以我就没有加条件

34,575

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧