Solved

SQL Distinct on multiple columns

Posted on 2008-06-23
3
1,898 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now