mssql 时间比较问题
数据库结构:
id hit times
1 1 2008年2月19日
2 26 2008年2月27日
3 32 2008年2月27日
select sum(hit)as wk,times from hit where id=1005 group by times
得到结果:
1 2009年12月10日
2 2009年12月16日
1 2009年12月17日
1 2009年12月19日
983 2009年12月1日
1262 2009年12月2日
1201 2009年12月3日
857 2009年12月4日
951 2009年12月5日
924 2009年12月6日
312 2009年12月7日
4 2009年12月8日
2 2009年12月9日
select sum(hit)as wk,times from hit where id=1005 and replace(replace(replace(times,'年','-'),'月','-'),'日','')>=replace(replace(replace('2009年12月20日','年','-'),'月','-'),'日','') group by times
得到结果:
1201 2009年12月3日
857 2009年12月4日
951 2009年12月5日
924 2009年12月6日
312 2009年12月7日
4 2009年12月8日
2 2009年12月9日
奇怪为何最后的语句会得到这样的结果?求高人指点。。
你REPLACE完了是不是应该用CONVERT转一下再比较。。。
SQL code:
select sum(hit)as wk,times from hit where id=1005 and CONVERT(DATETIME,replace(replace(replace(ti
相关问答:
有意者请联系yushan-33@hotmail.com / 18821146311
Microsoft SQL Administrator
Job Description:
A detail oriented Microsoft SQL Administratorwith excellent problem solving, analyti ......
有意者请联系yushan-33@hotmail.com / 18821146311
Microsoft SQL Administrator
Job Description:
A detail oriented Microsoft SQL Administratorwith excellent problem solving, analyti ......
MSSQL某字段某些内容替换
例如表 S_ORDER , 字段 NAME
AAA咀asdfasd
  ......
mssql的企业管理器中添加mysql的链接服务器怎么操作,我想用企业管理的面板实现,不要代码形式的。详细过程,谁能说说嘛?
引用
直接填写你的服务器地址,端口号,账号及密码就可以了。
你这样说和没说 ......