troubleshooting Question

select distinct on one field only

Avatar of bendecko
bendecko asked on
Microsoft SQL Server
5 Comments1 Solution1820 ViewsLast Modified:
Hi I'd like to do a DISTINCT query but just on one Field.

E.g.

zip              City               State              Area

10001      NEW YORK      New York      EMPIRE STATE
10001      NEW YORK      New York      G P O
10001      NEW YORK      New York      GREELEY SQUARE
10001      NEW YORK      New York      MACYS FINANCE
10001      NEW YORK      New York      MANHATTAN
10001      NEW YORK      New York      NEW YORK
10001      NEW YORK      New York      NEW YORK CITY
10001      NEW YORK      New York      NY
10001      NEW YORK      New York      NY CITY
10001      NEW YORK      New York      NYC
10002      NEW YORK      New York      KNICKERBOCKER
10002      NEW YORK      New York      MANHATTAN
10002      NEW YORK      New York      NEW YORK
10002      NEW YORK      New York      NYC

When I do a SELECT DISTINCT on here.. I get all rows.

Whereas what I want is to get each zip code out and then the distinct extra columns?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros