Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

aliased column is ambiguous in where clause - forum topic by matt.h

$
0
0

Is there a way to reference an aliased column so it doesn't throw a column is ambiguous error (without renaming the alias)? Example:
Select coalesce(a.dob, b.birth_date) as dob
From db.table1 a
Join db.table2 b (on a.field1 = b.field1)
Where dob = '1900-01-01'  <--- throws an error because it doesn't know if dob is coming from db.table1 or the aliased field that I want to alias dob.
This is my silly work around but wondered if there is a better solution:
Select q.dob2 as dob
From(
Select coalesce(a.dob, b.birth_date) as dob2
From db.table1 a
Join db.table2 b (on a.field1 = b.field1)
Where dob2 = '1900-01-01'
) q

Forums: 

Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>