Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: SQL Server
Expertise: Beginner
Dec 14, 1999



Application Security Testing: An Integral Part of DevOps

Selecting Rows Based on a Distinct Value

I have a table in my SQL 7 database that, among other values, contains e-mails. There are duplicate e-mail values in this table. I want to extract one record for each unique e-mail:
Select Distinct Email, *  From Entries
This doesn't work, but hopefully you can get the idea what I'm trying to do here.

How can I do this?

I think your issue is including the star in the query. Try pulling the distinct e-mails out by themselves first, as in:

select distinct e-mail, whatever_you_use_for_a_primary_key from entries into #temp
then you can collect the rest of the fields you want from ENTRIES by joining on the unique e-mails.
DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date