将多个SQL语句合并为一个

时间:2019-01-10 23:36:42

标签: sql sql-server sapb1

我在Sap b1中使用了以下SQL语句,以基于组件信息获取信息。

可以正常工作/我可以获取数据并正常工作,但看起来这段代码会影响性能,在记录之间导航时速度会变慢。

什么是使它表现更好的最佳方法?

  @STORE1 = SQL(SELECT T2."U_LoadPSI" FROM "A_SANDBOX"."ITT1"  T1 Inner Join OITM T2 on T2."ItemCode" = T1."Code" WHERE T1."Father" = $[$5.0.0] and  T1."Code"  LIKE '20%'); 
IF (@STORE1 !='') 
BEGIN  
Set($[$BOYX_80.0.0]|@STORE1); 
END 
ELSE 
BEGIN  
Set($[$BOYX_80.0.0]|''); 
END

    @STORE2 = SQL(SELECT T2."U_LoadLbs" FROM "A_SANDBOX"."ITT1"  T1 Inner Join OITM T2 on T2."ItemCode" = T1."Code" WHERE T1."Father" = $[$5.0.0] and  T1."Code"  LIKE '20%'); 
IF (@STORE2 !='') 
BEGIN  
Set($[$BOYX_81.0.0]|@STORE2); 
END 
ELSE 
BEGIN  
Set($[$BOYX_81.0.0]|''); 
END

    @STORE3 = SQL(SELECT T2."U_TireSize" FROM "A_SANDBOX"."ITT1"  T1 Inner Join OITM T2 on T2."ItemCode" = T1."Code" WHERE T1."Father" = $[$5.0.0] and  T1."Code"  LIKE '20%'); 
IF (@STORE3 !='') 
BEGIN 
Set($[$BOYX_38.0.0]|@STORE3); 
END 
ELSE 
BEGIN  
Set($[$BOYX_38.0.0]|''); 
END

    @STORE4 = SQL(SELECT T2."U_Size" FROM "A_SANDBOX"."ITT1"  T1 Inner Join OITM T2 on T2."ItemCode" = T1."Code" WHERE T1."Father" = $[$5.0.0] and  T1."Code"  LIKE '50%' ); 
IF (@STORE4 !='') 
BEGIN 
Set($[$BOYX_39.0.0]|@STORE4); 
END 
ELSE 
BEGIN  
Set($[$BOYX_39.0.0]|''); 
END

    @STORE5 = SQL(SELECT T2."U_Color" FROM "A_SANDBOX"."ITT1"  T1 Inner Join OITM T2 on T2."ItemCode" = T1."Code" WHERE T1."Father" = $[$5.0.0] and  T1."Code"  LIKE '50%'); 
IF (@STORE5 !='') 
BEGIN 
Set($[$BOYX_82.0.0]|@STORE5); 
END 
ELSE 
BEGIN  
Set($[$BOYX_82.0.0]|''); 
END

0 个答案:

没有答案