Try this
--Raj
Main Topics
Browse All TopicsI am giving 500 points cuz i need this quick, but I am sure its pretty simple. I have a query like:
Select id, userid, name, lastname
I get 100 records, but some of them have the same 'userid', i want to display them only once instead of multiple times, so I get like 50 results where the records that are repeated by the 'userid' only show once.
Select id, (userid only once), name, lastname
Hope that makes sense.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
One more thing, once I added the MIN I got an error saying that "Alienid" is not part of the group by clause. This is my query:
SELECT c.Id, c.CaseId, c.EmpId, MIN (c.AlienId), c.FirmAddressId, c.ExpDate,d.FirstNm, d.MiddleNm, d.LastNm ,d.email, d.Nistatus, d.ExpiresOn, c.FirmId, c.MainCase , d.NIVMaxStatus, b.MaidenNm,e.Processcatalo
FROM Cases c LEFT JOIN Users as d ON c.AlienID = d.UserID INNER JOIN Processcatalog as e ON c.Process = e.ProcesscatalogID INNER JOIN Users as b ON c.empid = b.userid LEFT JOIN Activities_Misc as f on f.act_misc_id = c.defaultrecpt
WHERE c.EmpID=MMColParam AND c.archived = 0 and c.firmid = MMColParam2
ORDER BY d.LastNm, c.caseid
This is the actual final query but I get an error, error is attached.
SELECT MIN (c.AlienID), d.LastNm, d.FirstNm, d.email, d.Nistatus, d.NIVMaxStatus
FROM Cases c
LEFT JOIN Users as d ON c.AlienID = d.UserID
INNER JOIN Users as b ON c.empid = b.userid
WHERE c.EmpID=MMColParam AND c.archived = 0 and c.firmid = MMColParam2
GROUP BY MIN (c.AlienID), d.LastNm, d.FirstNm, d.email, d.Nistatus, d.NIVMaxStatus
ORDER BY d.LastNm, c.caseid
Business Accounts
Answer for Membership
by: DanielWilsonPosted on 2009-11-05 at 09:00:43ID: 25751523
Select min(ID), userid, name, lastname
Group By userid, name, lastname
I am assuming that a UserID matches only a single name and lastname. If otherwise, we'll have to change the aggregation & grouping.