sqlamazon-redshift

select column 'name' or 'nm' from table 'tb2' only 1 column will exist at a time either 'name' or 'nm'


in amazon redshift table i need to select column from table tb2 following conditions:

pg_get_late_data_columns and information schema not working for me


Solution

  • This will need to be some form of dynamic SQL. You should be able to get the info you need in pg_table_def - https://docs.aws.amazon.com/redshift/latest/dg/r_PG_TABLE_DEF.html