techele
techele

Reputation: 305

Teradata join statement syntax

I have been given following sql, which seems to have issue while importing through apache calcite.

SELECT DISTINCT a.abc, t.desc, m.qprs, m.mpn,
  m.ohug, p.tre, p.status
  FROM (table_a m table_b p 
          ON m.mat = p.mat)
          INNER JOIN table_c t ON t.mat = m.mat
  WHERE t.lang = 'E' AND p.plant LIKE '110%'
  ORDER BY p.plant desc;

Can someone with detailed knowledge of Teradata confirm, if this syntax is right?

If not, what could be right syntax?

Thanks in advance.

Upvotes: 0

Views: 76

Answers (2)

django
django

Reputation: 210

To add to Gordons answer , The keyword desc is a reserved keyword. Better use [] around this to avoid error.

SELECT DISTINCT a.abc, t.[desc], m.qprs, m.mpn, m.ohug, p.tre, p.status FROM table_a m INNER JOIN
 table_b p 
 ON m.mat = p.mat INNER JOIN
 table_c t
 ON t.mat = m.mat WHERE t.lang = 'E' AND p.plant LIKE '110%' ORDER BY p.plant desc;

Upvotes: 0

Gordon Linoff
Gordon Linoff

Reputation: 1270633

That syntax is not correct.

SELECT DISTINCT a.abc, t.desc, m.qprs, m.mpn, m.ohug, p.tre, p.status
FROM table_a m INNER JOIN
---------------^ missing keyword
     table_b p 
     ON m.mat = p.mat INNER JOIN
     table_c t
     ON t.mat = m.mat
WHERE t.lang = 'E' AND p.plant LIKE '110%'
ORDER BY p.plant desc;

The parentheses are not needed, although they should be allowed.

Upvotes: 1

Related Questions