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
Combobox values updated when selected versus typed
specified field could refer to more than one table listed in the FROM clause of SQL statement
IEENCODE.DLL.000
SMPTE time code input mask not working
How do you count the number of folders in an Exchange 2007 mailbox?
event id 1639 warning message on blackberry server
Getting GC error trying to run rendom /upload
Userenv 1054, DnsApi 11197 and Dhcp 1003 event viewer logs
UPDATE OPENQUERY (LINKEDSERVER, 'SELECT...) SET FIELD = #
Can't exit design mode because control can not be created