cancel
Showing results for 
Search instead for 
Did you mean: 

SAP HANA query using joins

former_member229757
Participant
0 Kudos

Hi friends

How to join more than 2 tables using sql hana query. while executing the below query am getting error.

first 2 joins are working fine while linking with join 3 error showing. How to achieve this query. Highlighted bold lines having the problem

BEGIN

OUT1 = SELECT ARTICLE_ID, COLOR_CODE, AMOUNT_SOLD FROM "vinoth"."SHOP_FACTS";

OUT2 = SELECT ARTICLE_ID,CATEGORY,SALE_PRICE,FAMILY_NAME FROM "vinoth"."ARTICLE_LOOKUP";

JOIN1 =  SELECT T1.ARTICLE_ID, T1.COLOR_CODE, T1.AMOUNT_SOLD,T2.CATEGORY,T2.SALE_PRICE,T2.FAMILY_NAME

          FROM

          :OUT1 AS T1

          LEFT OUTER JOIN

          :OUT2 AS T2

          ON

          T1.ARTICLE_ID = T2.ARTICLE_ID;

  var_out = SELECT ARTICLE_ID,CATEGORY,SALE_PRICE,COLOR_CODE,AMOUNT_SOLD,FAMILY_NAME FROM :JOIN1;

 

 

OUT3 = SELECT ARTICLE_ID,COLOR_CODE,CATEGORY,FAMILY_CODE FROM "vinoth"."ARTICLE_COLOR_LOOKUP";

JOIN2 = SELECT T3.ARTICLE_ID,T3.COLOR_CODE,T3.CATEGORY,T3.FAMILY_CODE

  FROM

  :JOIN1 AS T3

  LEFT OUTER JOIN

  :OUT3 AS X

  ON

  T3.ARTICLE_ID=X.ARTICLE_ID

  var_out = SELECT ARTICLE_ID, COLOR_CODE,CATEGORY,FAMILY_CODE

     

END

Thanks

Vinoth

Accepted Solutions (0)

Answers (1)

Answers (1)

pfefferf
Active Contributor
0 Kudos

And what exact error message do you get?

Some things what can be seen from the code:

  • The last three statements are not closed with a semi-colon (JOIN2 = ...; var_out = ...; END;).
  • The select for JOIN2 refers to T3.FAMILY_CODE. But this table (T3 aka JOIN1) has no such column. It has just a column FAMILY_NAME.

Regards,

Florian

test_community
Active Participant
0 Kudos

Hi,

I think your problem is that T3 don't have FAMILY_CODE, the X does (see bold).

JOIN2 = SELECT T3.ARTICLE_ID,T3.COLOR_CODE,T3.CATEGORY,T3.FAMILY_CODE

  FROM

  :JOIN1 AS T3

  LEFT OUTER JOIN

  :OUT3 AS X

  ON

  T3.ARTICLE_ID=X.ARTICLE_ID

  var_out = SELECT ARTICLE_ID, COLOR_CODE,CATEGORY,FAMILY_CODE

Regards,

Vasilis