Solved

SQL Distinct on multiple columns

Posted on 2008-06-23
3
1,901 Views
Last Modified: 2008-07-14
I want to get the distinct set of rows based on the uniqueness of multiple columns

ex: I have a table last,first whose data is:

smith, john
smith, john
smith, fred

i want to run SQ - something similar to:
select distinct last,first from table;

should return:
smith,john
smith,fred
0
Comment
Question by:pmsguy
3 Comments
 
LVL 4

Accepted Solution

by:
zx10r earned 250 total points
ID: 21850986
why don't you just use GROUP BY
0
 
LVL 17

Expert Comment

by:HuyBD
ID: 21852842
Could you explain more
0
 
LVL 28

Assisted Solution

by:gamebits
gamebits earned 250 total points
ID: 21884112
In your example a simple distinct clause will return what you are looking for, would be different though if you add a third column

smith, john, 1
smith, john, 2
smith, fred, 1

Then a distinct query would return all three of them.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Fore-Foreword Today (2016) Maxmind has a new approach to the distribution of its data sets.  This article may be obsolete.  Instead of using the examples here, have a look at the MaxMind API (https://www.maxmind.com/en/geolite2-developer-package). …
More Fun with XML and MySQL – Parsing Delimited String with a Single SQL Statement Are you ready for another of my SQL tidbits?  Hopefully so, as in this adventure, I will be covering a topic that comes up a lot which is parsing a comma (or other…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question