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
How to host a web site on IIS
Microsoft SQL 2005
Change default editor in Outlook 2010 Beta.
Preventing Outlook Calendar Conflicts
Can't run eseutil on Exchange 2k3 server
file mountmgr.sys caused an unexpected error 256 at line 5964
Access Report to PDF without Save As Dialog
How Can I Create a Unique Sequential Number for Only Those Records in a Table That Meet a Criteria
LINQ - Contains for IN statement not working?
How can I substract todays dates from the initial date?