简体   繁体   中英

AS400/Iseries/DB2 SQL - Select unique view / logical

I'm looking for some help creating a view / logical over the below. Ideally I want to ignore the dept column, and then select the unique users and email addresses. For example you can see below USER1 works for 2 departments... but I only want to see them once in the view/logical.

Any help on the syntax for this would be great. My select unique always seems to give the wrong result as it still references DEPT, therefore I still see all records

| USER| DEPT| EMAIL|
|:---- |:------:| -----:|
| USER1| SALES| user1@email.com|
| USER2| SALES| user2@email.com|
| USER1| FINANCE| user1@email.com|
| USER4| IT| user4@email.com|

SELECT DISTINCT USER, EMAIL FROM TABLE?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM