将MSSQL外部应用转换为Netezza左连接

时间:2017-06-21 15:25:48

标签: sql database-migration netezza

所以我有一个场景,我们有两个环境,一个是MSSQL,另一个是IBM Netezza,有点过时(ANSI-92)。我已经构建了MSSQL查询,但我不熟悉如何将MSSQL中的外部应用转换为符合ANSI-92的代码。

我知道使用较旧的环境基本上不赞成,但这是我无法控制的。谢谢你们给予的任何帮助。

以下是我要转换的部分:

Outer Apply 
(select top 1 idclinicnumber, idorders                              
from orders where idClinicNumber = oGrandChild.idClinicNumber                               
and idpatient = oGrandChild.IdPatient                               
and IsGeneratedInError <> 1                                 
and idordertype not in (14, 18)                                 
and iddrugservice = pGrandChild.iddrugservice                               
and DateStartOrder > oGrandChild.datestartorder                                 
and isNull(datestoporder, getdate()) >= DateStartOrder  
and isnull(DateDC, GETDATE()) >= DateStartOrder order by DateStartOrder) 
oFirstMedOrderAfterID 

outer apply (select top 1 idclinicnumber, idservice, dateservice, 
DoseDelivered from service where idclinicnumber = 
oFirstMedOrderAfterOrder.idClinicNumber and idorders = 
oFirstMedOrderAfterOrder.idorders and IdServiceStatus = 1 order by 
DateService) oFirstService1AfterID

outer apply (select top 1 idclinicnumber, idservice, dateservice, 
DoseDelivered from service where idclinicnumber = 
oFirstMedOrderAfterOrder.idClinicNumber and idorders = 
oFirstMedOrderAfterOrder.idorders and dateservice > 
oFirstService1AfterID.DateService and IdServiceStatus = 1 order by 
DateService) oFirstService2AfterID                                                  

0 个答案:

没有答案