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
Trying to pass a SQL parameter to crystal reports in a command statement
Allowing earlier dates in datetime picker control than 1753
How do I get rid of double contacts in Outlook?
How to copy all the Children of an InkCanvas to another inkCanvas
Access 2003 NOT IN (select subquery) doesn't work
Access project - How to undo changes in a continuous form
Extract data from XML using sql server 2005Question
Timer function to automate Access
exchange 2007
SBS 2003 hangs will setting up personalized settings for Internet Explorer after IE7 upgrade