[求助]帮俺写意sql语句,急用,在线等。。。。(100)

  • 主题发起人 主题发起人 sunke520
  • 开始时间 开始时间
S

sunke520

Unregistered / Unconfirmed
GUEST, unregistred user!
sql server里面有张表astation date zhi52112 1999-1-1 8:00:00 2052112 1999-1-1 9:00:00 3252112 1999-1-1 10:00:00 1052112 1999-1-1 11:00:00 1152112 1999-1-1 12:00:00 2352112 1999-1-1 13:00:00 3352112 1999-1-1 14:00:00 1252112 1999-1-1 15:00:00 5652112 1999-1-1 16:00:00 4752112 1999-1-1 17:00:00 1352112 1999-1-1 18:00:00 2352112 1999-1-1 19:00:00 3452112 1999-1-1 20:00:00 5252112 1999-1-1 21:00:00 4652112 1999-1-1 22:00:00 4552112 1999-1-1 23:00:00 4652112 1999-1-1 24:00:00 6352112 1999-1-2 8:00:00 2052112 1999-1-2 9:00:00 3252112 1999-1-2 10:00:00 1052112 1999-1-2 11:00:00 1152112 1999-1-2 12:00:00 2352112 1999-1-2 13:00:00 3352112 1999-1-2 14:00:00 1252112 1999-1-2 15:00:00 5652112 1999-1-2 16:00:00 4752112 1999-1-2 17:00:00 1352112 1999-1-2 18:00:00 2352112 1999-1-2 19:00:00 3452112 1999-1-2 20:00:00 5252112 1999-1-2 21:00:00 4652112 1999-1-2 22:00:00 4552112 1999-1-2 23:00:00 4652112 1999-1-2 24:00:00 6352112 1999-1-3 8:00:00 2052112 1999-1-3 9:00:00 3252112 1999-1-3 10:00:00 1052112 1999-1-3 11:00:00 1152112 1999-1-3 12:00:00 2352112 1999-1-3 13:00:00 3352112 1999-1-3 14:00:00 1252112 1999-1-3 15:00:00 5652112 1999-1-3 16:00:00 4752112 1999-1-3 17:00:00 1352112 1999-1-3 18:00:00 2352112 1999-1-3 19:00:00 3452112 1999-1-3 20:00:00 5252112 1999-1-3 21:00:00 4652112 1999-1-3 22:00:00 4552112 1999-1-3 23:00:00 4652112 1999-1-3 24:00:00 63现要查询52112站1999-1-1到1999-1-3 8点到12点的值,求大侠帮忙写这sql语句。。。急。在线等。。查询的预期结果如下:52112 1999-1-1 8:00:00 2052112 1999-1-1 9:00:00 3252112 1999-1-1 10:00:00 1052112 1999-1-1 11:00:00 1152112 1999-1-1 12:00:00 2352112 1999-1-2 8:00:00 2052112 1999-1-2 9:00:00 3252112 1999-1-2 10:00:00 1052112 1999-1-2 11:00:00 1152112 1999-1-2 12:00:00 2352112 1999-1-3 8:00:00 2052112 1999-1-3 9:00:00 3252112 1999-1-3 10:00:00 1052112 1999-1-3 11:00:00 1152112 1999-1-3 12:00:00 23
 
1999-1-1->date1 datetime1999-1-3->date2 datetime8点->hour1 int12点->hour2 intSelect station,date,zhi From aWhere station=52112 And date>=date1 and date<=date2 and Cast(datename(hh,date) as int)>(hour1-1) and Cast(datename(hh,date) as int)<(hour2+1)
 
select * from yourTable where datepart(day,date)>=1 and datepart(day,date)<4/ and datepart(hour,date)>0 and datepart(hour,date)<12
 
select * from a where station=52112and convert(varchar,date,111) between '1999-01-01' and '1999-01-03'and convert(varchar,date,108) between '08:00:00' and '12:00:00'
 
谢谢楼上的朋友帮忙。。十分感谢
 

Similar threads

I
回复
0
查看
876
import
I
D
回复
0
查看
2K
DelphiTeacher的专栏
D
A
回复
0
查看
564
Andreas Hausladen
A
D
回复
0
查看
2K
DelphiTeacher的专栏
D
后退
顶部