请教一条SQL语句

hui1202 2007-05-17 04:25:58
a b c d e f g
2007 5 16 9 0 2 2
2007 5 16 10 0 0 0
2007 5 16 11 0 7 7
2007 5 16 12 0 0 0
2007 5 16 13 0 0 0
2007 5 16 14 1 2 22
2007 5 16 15 3 6 37
2007 5 16 16 1 2 23
2007 5 16 18 1 2 14
2007 5 16 19 1 0 21
2007 5 16 20 0 0 12
2007 5 16 21 1 3 9
2007 5 16 23 0 1 8
2007 5 17 0 2 2 27
2007 5 17 1 1 0 10
2007 5 17 2 0 0 3
2007 5 17 3 0 0 12
2007 5 17 4 1 0 15

我想取出c=16 d=9至c=17 d=3的之间的所有记录,请问这条SQL语句怎么写
...全文
283 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
hhjll 2007-07-01
  • 打赏
  • 举报
回复
aaa
akuan956 2007-05-18
  • 打赏
  • 举报
回复
路过学习一下,不给分也可以!
码出钞能力 2007-05-18
  • 打赏
  • 举报
回复
select * from tablename
where a=2007 and b=5 and (c=16 and d>=9 or c=17 and d<=3)
hui1202 2007-05-17
  • 打赏
  • 举报
回复
我取出来的是null啊,我的是mysql库,请问语法是一样吗
wgzaaa 2007-05-17
  • 打赏
  • 举报
回复
能得到与君的夸奖很高兴
wgzaaa 2007-05-17
  • 打赏
  • 举报
回复
where cast(rtrim(c)+':'+rtrim(d) as datetime)
between cast('16:9' as datetime) and cast('17:3' as datetime)

gahade 2007-05-17
  • 打赏
  • 举报
回复
wgzaaa() 的方法挺好~!
qys2000 2007-05-17
  • 打赏
  • 举报
回复
select * from
(select * from Table where c>=16 and d<=9)
where c<=17 and d>=3
hui1202 2007-05-17
  • 打赏
  • 举报
回复
其实很简单,就是取出2007 年 5 月 16 日 9 时 至 2007 年 5 月 17 日 3 时 之间的数据
wgzaaa 2007-05-17
  • 打赏
  • 举报
回复
select * from 表 where right('00'+rtrim(c),2)+right('00'+rtrim(d),2)
between 1609 and 1703
hui1202 2007-05-17
  • 打赏
  • 举报
回复
没什么关系。。。。d是24小时,c是日期
shuai45 2007-05-17
  • 打赏
  • 举报
回复
不知道我理解的对否c=16 d=9至c=17 d=3 其实就是取得c>=16 d>=3 的所有记录吧~
不对的化LZ在解释哈
~~
 select * from yonghu where c>=16 and d>=3
Tongls 2007-05-17
  • 打赏
  • 举报
回复
d与c有什么关系???

不然没有办法写。
hhjll 2007-05-17
  • 打赏
  • 举报
回复
select * from
(select * from Table where c>=16 and d<=9)
where c<=17 and d>=3

34,593

社区成员

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

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