Distinct with Count and SQl Server 2005

Posted by chopps on Stack Overflow See other posts from Stack Overflow or by chopps
Published on 2010-04-10T00:56:40Z Indexed on 2010/04/10 15:23 UTC
Read the original article Hit count: 421

Filed under:
|
|

Hey everyone,

Trying to work on a query that will return the top 3 selling products with the three having a distinct artist. Im getting stuck on getting the unique artist.

Simplified Table schema

Product
  ProductID
  Product Name
  Artist Name

OrderItem
 ProductID
 Qty


So results would look like this...

PID    artist                 qty
34432, 'Jimi Hendrix',        6543
54833, 'stevie ray vaughan'   2344
12344, 'carrie underwood',    1

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about distinct