Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL Distinct on multiple columns

Posted on 2008-06-23
3
Medium Priority
?
1,907 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 4

Accepted Solution

by:
zx10r earned 750 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 750 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Creating and Managing Databases with phpMyAdmin in cPanel.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

705 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