日期:2014-05-18 浏览次数:20540 次
select xingming,ruzhishijian,lizhishijian,datediff(day,ruzhishijian ,lizhishijian) as '在职天数' from d_yuangong
------解决方案--------------------
报什么错?
select xingming as 姓名,ruzhishijian as 入职时间,lizhishijian as 离职时间,datediff(day,ruzhishijian,lizhishijian) as 在职天数 from d_yuangong
------解决方案--------------------
根据姓名排序得到序号。
select ROW_NUMBER OVER(PARTITION BY xingming) AS 序号,xingming AS 姓名,ruzhishijian AS 入职时间,lizhishijian AS 离职时间,DATEDIFF(DAY,CAST(ruzhishijian AS DATE), CAST(lizhishijian AS DATE)) AS 在职天数 from d_yuangong
------解决方案--------------------
不好意思啊 楼主,上面代码错了,试试底下的吧
select ROW_NUMBER() OVER(order BY xingming) AS 序号,xingming AS 姓名,ruzhishijian AS 入职时间,lizhishijian AS 离职时间,DATEDIFF(DAY,CAST(ruzhishijian AS DATE), CAST(lizhishijian AS DATE)) AS 在职天数 from d_yuangong
------解决方案--------------------
select ROW_NUMBER() OVER(order BY xingming) AS 序号,xingming AS 姓名,ruzhishijian AS 入职时间,lizhishijian AS 离职时间,DATEDIFF(DAY,CAST(ruzhishijian AS DATE), CAST(lizhishijian AS DATE)) AS 在职天数 from d_yuangong