SQL DISTINCT Value Question

Posted by CPOW on Stack Overflow See other posts from Stack Overflow or by CPOW
Published on 2010-06-03T01:14:14Z Indexed on 2010/06/03 1:24 UTC
Read the original article Hit count: 412

Filed under:
|
|

How can I filter my results in a Query? example

I have 5 Records

John,Smith,apple
Jane,Doe,apple
Fred,James,apple
Bill,evans,orange
Willma,Jones,grape

Now I want a query that would bring me back 3 records with the DISTINCT FRUIT, BUT... and here is the tricky part, I still want the columns for First Name , Last Name. PS I do not care which of the 3 it returns mind you, but I need it to only return 3 (or what ever how many DISTINCT fruit there are.

ex return would be

John,Smith,apple
Bill,evans,orange
Willma,Jones,grape

Thanks in advance I've been banging my head on this all day.

© Stack Overflow or respective owner

Related posts about sql

Related posts about group-by