• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

SQL函数在MS SQL SERVER中可以mysql不行!该怎么解决

mysql 搞代码 7年前 (2018-06-05) 137次浏览 已收录 0个评论

SQL函数在MS SQL SERVER中可以mysql不行!
时间是2012-12-12 12:12:12
现在我要把后面的时、分、秒 去掉 
select data_Start = convert(varchar(10),data_Start ,120) from Statistical
显示的没有时、分、秒 只有2012-12-12
放到mysql中报错
mysql 语句如下:

select date=convert(varchar(10),date ,120) from owa_isa
错误提示:
[Err] 1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘VARCHAR(10) date 120) from owa_isa’ at line 1

——解决方案——————–

探讨

看来我要写的具体点!
select 时间字段=convert(varchar(10),时间字段,120) from owa_isa
我现在读取不要显示时 分 秒 上面的在sql中可以,到mysql中不行!why!

——解决方案——————–
WEEK(date[,mode]) 

This function returns the week number for date. The two-argument form of WEEK() allows you to specify whether the week starts on Sunday or Monday and whether the return value should be in the range from 0 to 53 or from 1 to 53. If the mode argument is omitted, the value of the default_week_format system variable is used. See Section 5.2.3, “System Variables”. 

The following table describes how the mode argument works. 

First day
Mode of week Range Week 1 is the first week … 
0 Sunday 0-53 with a Sunday in this year 
1 Monday 0-53 with more than 3 days this year 
2 Sunday 1-53 with a Sunday in this year 
3 Monday 1-53 with more than 3 days this year 
4 Sunday 0-53 with more than 3 days this year 
5 Monday 0-53 with a Monday in this year 
6 Sunday 1-53 with more than 3 days this year 
7 Monday 1-53 with a Monday in this year 

select sum(使用流量的和),week(时间字段,1)as t
from Statistical where 1=1 group by week(时间字段,1)


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:SQL函数在MS SQL SERVER中可以mysql不行!该怎么解决

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址