这个小问题,搞了好几次,记录一下
SQL SERVEL 合并表之间列:如下所示
合并前:
select a.DisplayTime ,count(c.InsertDate) as AppointCount from TempDataNodeTime a left join TableAppointmentMainInfo c on substring(convert(char(7) ,c.InsertDate, 21),1,7)=a.DisplayTime group by a.[DisplayTime] select a.DisplayTime , count(b.createdate) as ApplyCount from TempDataNodeTime a left join HISAPPLICATIONFORM b on substring(convert(char(7) ,b.createdate, 21),1,7)=a.DisplayTime group by a.[DisplayTime]
合并后:
select aa.DisplayTime,aa.AppointCount,bb.ApplyCount from ( select a.DisplayTime ,count(c.InsertDate) as AppointCount from TempDataNodeTime a left join TableAppointmentMainInfo c on substring(convert(char(7) ,c.InsertDate, 21),1,7)=a.DisplayTime group by a.[DisplayTime] ) as aa, ( select a.DisplayTime , count(b.createdate) as ApplyCount from TempDataNodeTime a left join HISAPPLICATIONFORM b on substring(convert(char(7) ,b.createdate, 21),1,7)=a.DisplayTime group by a.[DisplayTime] ) as bb where aa.DisplayTime =bb.DisplayTime
博客内容主要用于日常学习记录,内容比较随意,如有问题,还需谅解!!!