Microsoft
Software
Hardware
Network
Question : Select distinct based on 2 fields
I have a table, Buyer. It has BuyerCode and Country columns. I want to select distinct based on 2 columns combined. For example, I have 1st record: Buyer1, USA, 2nd record: Buyer1, Canada, record 3: Buyer2, USA etc. I want to select both Buyer1 since its country is different. If I do Select Distinct BuyerCode, I only get Buyer1 with USA. How do I do it?
I appreciate your suggestions in advance. Thank you.
Answer : Select distinct based on 2 fields
SELECT BuyerCode, Country
FROM Buyer
GROUP BY BuyerCode, Country
-- or --
SELECT DISTINCT BuyerCode, Country
FROM Buyer
They should return the same results.
Random Solutions
php like zen cart want return to be categories instead of products
Windows Server 2008 R2: missing start menu of installed applications
Team Foundation Server 2010, deleted web site problem
get 550 5.7.1. Unable to relay for specific domains....
How to Stop Procedure Running after Message Box Displayed
Need help to seperate Select output using TABs
PHP QUESTION - OSCOMMERCE - How to remove short description underneath products in Oscommerce 2.2
How to calculate OSPF cost?
sql job with proxy agent failed to execute
How do i verify an age element using javascript?