Microsoft
Software
Hardware
Network
Question : Union Query duplicates
SQL Server 2008
I have a union query of names and email addresses.
There is also a column of MemberType
On one side of the union the Membertype is 1 on the other side, it is 2.
The results will contain duplicate email addresses.
I need to alter the query so that if a duplicate email exists then we choose the MemberType of 1 before we choose the MemberType of 2, thus ignoring MemberType 2 if a MemberType 1 exists.
Thanks
Answer : Union Query duplicates
SELECT name, MIN(MemberType) MemberType
FROM
(
SELECT name, MemberType FROM tbl1
UNION ALL
SELECT name, MemberType FROM tbl2
) t
GROUP BY name ;
Random Solutions
Problem with insert into query..
The difference between the server types "Web Front End" and "Stand-alone?"
What is difference between 2003 Standard and 2003 Datacenter servers?
Viewing Crystal Reports in an MFC SDI Application
Find computers in my network
variant for ServerName?
How do I export an Access Report to Excel and show the text/number fields correctly?
Acces to Path Denied error in VB.net
Export data from Access to multiple Excel files using a filtered string from a drop down list on a form
Erased C:\\Inetpub\wwwroot