数据库

位置:IT落伍者 >> 数据库 >> 浏览文章

初学者必读:精讲SQL中的时间计算语句[2]


发布日期:2019年11月20日
 
初学者必读:精讲SQL中的时间计算语句[2]

请问这个语句应该怎么去写?

if object_id(tablename) is not null drop table tablename

select as time_id as time_date as [year] as week_of_year 星期日 as [day]

into tablename

union select 星期一

union select 星期二

select time_id time_date [year] + cast(week_of_year as varchar()) + 周(

+ cast(month(week_begin) as varchar()) + / + cast(day(week_begin) as varchar()) +

+ cast(month(week_end) as varchar()) + / + cast(day(week_end) as varchar()) as week_of_year

from (select * dateadd(day datepart(weekday time_date) time_date) as week_begin

dateadd(day datepart(weekday time_date) time_date) as week_end from tablename) a

/*

time_id time_date year week_of_year

周(//)

周(//)

周(//)

*/

drop table tablename

[] [] [] [] []

               

上一篇:初学者必读:精讲SQL中的时间计算语句[3]

下一篇:初学者必读:精讲SQL中的时间计算语句[1]