标签:case oledb sql stat source desc station sda ted
--步骤1
select c.CodeName ‘点位‘,r.PASSDATETIME ‘时间‘,r.VLPN ‘车牌‘,r.VLPNCOLOR ‘车牌颜色‘,r.No ‘NO‘,sf ‘不透光‘,
case when IsValid=0 then ‘无效‘ else ‘有效‘ end ‘数据有效性‘,
(select top 1 a.stationcode from opendatasource(‘SQLOLEDB‘,‘Data Source=172.27.22.30;user ID=sa;password=hbjjgzx@skyland84‘).[Skyland.VIM.VIProv.ShanTou].dbo.[InspectionData] a where a.vlpn=r.vlpn and a.vlpncolor=r.vlpncolor order by IUIDATE desc) ‘检测站编码‘,
(select top 1 a.IUIDATE from opendatasource(‘SQLOLEDB‘,‘Data Source=172.27.22.30;user ID=sa;password=hbjjgzx@skyland84‘).[Skyland.VIM.VIProv.ShanTou].dbo.[InspectionData] a where a.vlpn=r.vlpn and a.vlpncolor=r.vlpncolor order by IUIDATE desc) ‘检测时间‘
--v.IUIDATE ‘检测时间‘
into #table1 from RemoteDetection r
inner join CD_BGStation c on r.StationCode=c.CodeValue
where DETECTIONSTATE=‘0‘ and PASSDATETIME>=‘2020-01-01 00:00:00‘
select t.点位,t.NO,t.不透光,t.车牌,t.车牌颜色,t.时间,t.数据有效性,s.stationName ‘检测站‘,t.检测时间 from #table1 t
inner join stationinfo s on t.检测站编码=s.stationcode
--步骤2
drop table #table1
标签:case oledb sql stat source desc station sda ted
原文地址:https://www.cnblogs.com/luoguixin/p/12975186.html