|
Archives of the TeradataForumMessage Posted: Tue, 18 Jul 2006 @ 12:31:55 GMT
Hi, The query written below is two step query: a. First step is to execute the below query with replacement for columnvalue and columnname (i.e 20 and column_1) Select CASE WHEN Row_Number() OVER(Order by 1) = 1 THEN 'SELECT '''||rtrim(databasename)|| '.' ||rtrim(tablename)||'.'||rtrim(columnname)||''',' || columnname || ' FROM ' || rtrim(databasename) || '.' || tablename || ' WHERE ' || rtrim(columnname) || ' =' || '20' ELSE 'UNION SELECT '''||rtrim(databasename)|| '.' ||rtrim(tablename)||'.'||rtrim(columnname)||''',' || columnname || ' FROM ' || rtrim(databasename) || '.' || tablename || ' WHERE ' || rtrim(columnname) || ' =' || '20' END FROM dbc.columns Where columnname='column_1'; b. The result of the first query needs to be execute to obtain the desired result. Regards, Vinod Sugur
| ||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||
Copyright 2016 - All Rights Reserved | ||||||||||||||||||||||||||||||||||||||||||||||||
Last Modified: 15 Jun 2023 | ||||||||||||||||||||||||||||||||||||||||||||||||