2017-06-06 123 views
0

我想在左外連接的HANA中構建一個查詢。我在where子句中使用(+)號。我經常在Oracle中這樣做;但在HANA中它返回一個語法錯誤。 HANA是否支持這種語法?HANA左外連接語法

select * 
FROM 
    "_SYS_BIC"."FinancialReporting.ReportingViews.Tech_Analytics/CV_LOA_FINANCIAL_DETAIL_GRA" F1, 
    "_SYS_BIC"."FinancialReporting.MasterData/CV_D_ACCOUNT_GRA" F2, 
    "_SYS_BIC"."FinancialReporting.MasterData/CV_D_COMPANY_GRA" F3, 
    "_SYS_BIC"."FinancialReporting.MasterData/CV_D_COSTCENTER_GRA" F4, 
    "_SYS_BIC"."FinancialReporting.ReportingViews/CV_LOA_MEASURES_LEVELS_TA_GRA" F5, 
    "_SYS_BIC"."FinancialReporting.MasterData/CV_D_VENDOR_GRA" F6 
WHERE 
    (F1."acct_nmbr" = F2."acct_nmbr") 
    AND (F1."company_cd" = F3."company_cd") 
    AND (F1."cost_center_cd" = F4."cost_center_cd") 
    AND (F1."acct_nmbr" = F5."acct_nmbr") 
    AND F1."vendor_cd" = F6."vendor_cd"(+) 
    AND (F1."acctg_dt" >= '2016-01-01' 
    AND F1."acctg_dt" <= '2016-02-01')) 
+1

這是由Oracle使用的舊樣式語法,它的挑剔標準。您需要使用顯式的JOIN:http://saphanatutorial.com/sap-hana-join-types/。你之所以沒有首先使用谷歌(或任何其他)搜索的原因? –

回答

4

你需要學會使用標準JOIN語法:

select * 
FROM "_SYS_BIC"."FinancialReporting.ReportingViews.Tech_Analytics/CV_LOA_FINANCIAL_DETAIL_GRA" F1 JOIN 
    "_SYS_BIC"."FinancialReporting.MasterData/CV_D_ACCOUNT_GRA" F2 
    ON F1."acct_nmbr" = F2."acct_nmbr" JOIN 
    "_SYS_BIC"."FinancialReporting.MasterData/CV_D_COMPANY_GRA" F3 
    ON F1."company_cd" = F3."company_cd" JOIN 
    "_SYS_BIC"."FinancialReporting.MasterData/CV_D_COSTCENTER_GRA" F4 
    ON F1."cost_center_cd" = F4."cost_center_cd" JOIN 
    "_SYS_BIC"."FinancialReporting.ReportingViews/CV_LOA_MEASURES_LEVELS_TA_GRA" F5 
    ON F1."acct_nmbr" = F5."acct_nmbr" LEFT JOIN 
    "_SYS_BIC"."FinancialReporting.MasterData/CV_D_VENDOR_GRA" F6 
    ON F1."vendor_cd" = F6."vendor_cd" 
WHERE F1."acctg_dt" >= '2016-01-01' AND F1."acctg_dt" <= '2016-02-01';