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

Distinct Logic - response (4) by dnoeth

$
0
0

Seems you want an indicator if a Name exists in Name1 or Name2, but your result doesn't match.

SELECT name, MAX(Name1), MAX(Name2)
FROM
 (
   SELECT name1 AS name, 'Y' AS Name1, 'N' AS Name2 FROM table1
   UNION ALL
   SELECT name2, 'N', 'Y' FROM table1
 ) AS dt
GROUP BY 1

 


Viewing all articles
Browse latest Browse all 14773

Trending Articles



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