OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to fix SQL for AWS Athena

  • Thread starter Thread starter SJ W
  • Start date Start date
S

SJ W

Guest
I'm moving SQL from Redshift to AWS Athena, but I'm having trouble because the SQL is giving me errors.

Code:
SELECT abc_name AS bca_name,
CASE
  WHEN name = 'aaa' THEN 'AAC'
  WHEN name = 'bbb' THEN 'BBA'
  WHEN name = 'ccc' THEN 'CCB'
END AS abc
FROM master_table
WHERE abc IS NOT NULL;

This SQL gave me an error: it says that there is no abc column because abc in the where clause is read earlier than in the select clause.

How can I get this to work?
<p>I'm moving SQL from Redshift to AWS Athena, but I'm having trouble because the SQL is giving me errors.</p>
<pre><code>SELECT abc_name AS bca_name,
CASE
WHEN name = 'aaa' THEN 'AAC'
WHEN name = 'bbb' THEN 'BBA'
WHEN name = 'ccc' THEN 'CCB'
END AS abc
FROM master_table
WHERE abc IS NOT NULL;
</code></pre>
<p>This SQL gave me an error: it says that there is no abc column because abc in the where clause is read earlier than in the select clause.</p>
<p>How can I get this to work?</p>
Continue reading...
 
Top