I've seen some posts similar to this, but nothing I have found really makes sense or works that I have tried. Essentially I need to select distinct on 3 columns, but return all the columns in the table. So far this is what I have:
SELECT *
FROM tbl1
WHERE tblKey IN (SELECT DISTINCT personKey, contentkey, EmailKey
FROM tbl1
WHERE (Application = 'website' OR Application =
'connect') AND
(contentKey IN (12, 13, 14, 16, 17, 18 , 19)) AND
(channelKey = 1))
The where statement in the subquery is because This only should apply to the content that is true to the where clause (obviously, but just making sure its known that Im not trying to remove duplicates in the where clause). This query obviously doesnt work since the tblKey is not in the subquery, but I cant figure out a way to work around this.