I have an SQL statement like this:
SELECT TOP 100 id,
lastname,
firstname,
address1,
city,
state,
zip
FROM leads
WHERE id > 100
ORDER BY id ASC
Now I want the ZIP to be different (not dup) for 100 result with 1 query statement like that.
SELECT TOP 100 l.id,
l.lastname,
l.firstname,
l.address1,
l.city,
l.state,
l.zip
FROM leads l
WHERE l.id = (select MIN (id) FROM leads l2 where l2.zip=l.zip)
ORDER BY l.id ASC