Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Teradata LEFT() function issue

Tags:

teradata

I run the following query against Teradata using SAS, and it works fine

SELECT LEFT(first_name,7) 
FROM testTab 

However, when I run the same query in Sql Assistant it throws an error : Expected something between keyword SELECT and keyword LEFT.

On my other computer, the above code runs on Sql Assistant.

So, my question is, why does the LEFT function work sometimes, and sometimes it doesn't ?

There are a lot of workarounds, but I want to know what the hell is going on with this LEFT function ?

like image 933
Emily Avatar asked Dec 11 '25 00:12

Emily


1 Answers

I'm not sure how the SAS version was running as LEFT is not a function in Teradata. LEFT is a keyword in Teradata because of LEFT OUTER JOIN. Perhaps SAS has some sort of parser/rewrite thing that changes it over to proper Teradata function.

At any rate, to do this in Teradata you can do:

 SELECT SUBSTRING(first_name FROM 1 FOR 7) FROM testtab
like image 105
JNevill Avatar answered Dec 15 '25 06:12

JNevill



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!