100分求个SQL语句 - MS-SQL Server / 应用实例
如何得到某季度或某月分特定时间段的数据
比如:1-3月,每天的早8点到晚5点数据,输入的时候输入一个起始时间输入一个结束时间2个参数.
我这么写的:
select * from yewutable
where
(timestamp between
convert(varchar(10),'2010-03-07 08:00:00',120)
and
convert(varchar(10),'2010-05-24 17:00:00',120)
)
and
(timestamp between
convert(varchar(8),'2010-03-07 08:00:00',108)
and
convert(varchar(10),'2010-05-24 17:00:00',108)
)
可"时分秒"的那个条件我没搞出来.请高手帮忙!谢谢
SQL code:
select * from yewutable
where [timestamp] between '2010-03-07 08:00:00' and '2010-05-24 17:00:00'
and convert(varchar(8),[timestamp],108) between '08:00:00' and '17:00:00'
-- convert函数的第一个参数是现实输出的长度,你把长度设置为19,就可以了,可以看下面的例子.
select convert(varchar(19),getdate(),120)
convert(varchar(8),callstarttimestamp ,108) between '01:00:00' and '02:00:00'
这个如何在'2010-05-24 17:00:00'中提取到?
convert(varchar(8),getdate(),108) 这样可以
convert(varchar(8),'2010-03-07 08:00:00',108) 这样却不行.
我是新手该怎么去转换呢?
学习下,高手
SQL code
Code highlighting produced by Actipro CodeHighlighter (freeware)
http
相关问答:
现在有两张表:文章主表A(articleId,articleTitle),文章评论表B(commentId,articleId,commentTitle)
现在我想实现这样的功能:列出文章列表,其中每篇文章标题下面列出此文章的前2个文章评论,请问sql语句怎么写啊 ......
tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......
我觉得mysql和sqlserver有共同的地方:
有个问题是关于表的锁问题:
进程A 进程B
select * from user where id in lock share mode(共享锁)
&nb ......
表数据
COL1 COL2 COL2 COL4 COL5
----------------------------------------------------------------------------------------------
2010-05-05 00:00 ......
SQL code:
rs.open "select * from guide where city_name='北京' order by pai desc",conn,1,1
do while not rs.eof or rs.bof
。。
。。
。。
rs.movenext
loop
这个sql语句在wap站里 本身有 ......