源数据
要达成的结果
SELECT A.Startdate,B.Startdate AS Enddate,isnull(A.orgcode4_name,'') as orgcode4_name,isnull(zige_name,'') as zige_name,isnull(zhizhcode_name,'') as zhizhcode_name,isnull(positioncode_name,'') as positioncode_nameFROM (SELECT ROW_NUMBER() over(order by startdate asc) as Seq,a.orgcode4_name,zige_name,zhizhcode_name,positioncode_name,convert(nvarchar(10),startdate,120) as startdate FROM alps_empinfo a,psnaccount bWHERE a.empcode=b.employeeIDand b.personID='2dffdd7e-5d5f-4739-a3b9-308071597259'and convert(nvarchar(20),a.startdate,120)<'2014-10-23') A,(SELECT (ROW_NUMBER() over(order by startdate asc)-1) as Seq,120) as startdate FROM (SELECT convert(nvarchar(10),(cast(startdate as datetime)-1),120) as startdate FROM alps_empinfo a,120)<'2014-10-23'UNION SELECT '2014-10-23') C) BWHERE A.Seq=B.Seq总结
以上是内存溢出为你收集整理的SqlServer 同表记录 上条记录结束日期为下条记录的开始日期的前一天全部内容,希望文章能够帮你解决SqlServer 同表记录 上条记录结束日期为下条记录的开始日期的前一天所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)