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
SQL datetime issue: The following 2 sections of code produce different results.
how to make changes to a mandatory profile
How to put range in excel cell?
Access 2003 between date query - want to select the date also typed in
Why does EE not allow file uploads with the .accdb extension?
Font in Cobo Box shrinks when I select from it
How can I enable a template item accoding to query result ?
What is a 'Database consistency check'?
Exactly what does Compact and Repair do?
Can I run the free MS Office Word viewer from command line to print a document?