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
How to get a Dell D800 to load Bios fully?
RegExp VBA for HTML tags - Needs assistance and explanations
AP running G and N
log4j called after unloading
Setting Reporting Services data driven subscription Using Web Service
Control object destruction during global destruction
iPhone 4 wont sync sub folder from Exchange
asp.net mssql I have a need to update records where the record column needs modifing in orde to match the Id value
Lightweight network management for mobile workforce
SSRS Combine two datasets into one data region - Must be in report not in SQL server