Quantcast
Channel: DISTINCT on one column and return TOP rows - Database Administrators Stack Exchange
Viewing all articles
Browse latest Browse all 4

DISTINCT on one column and return TOP rows

$
0
0

How do you query for three unique customers with the largest Purchase_Cost?

I want to apply the DISTINCT only on Customer_Name, but the query below applies the distinct on all three columns. How should I modify the query to obtain the desired output?

SELECT DISTINCT TOP 3 customer_name, order_no, Purchase_Cost  FROM PurchaseTable ORDER BY Purchase_Cost

enter image description here


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images