We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

help with selecting distinct

IUAATech
IUAATech asked
on
Medium Priority
273 Views
Last Modified: 2012-05-11
please refer to the sample data I have included.

I need to create a select statement that should work as follows:
for a given uid, if there is only a single record, then select that record.
for a given uid, if there are more than one record, and all the records have the same date, select one random record from that group.
for a given uid, if there are more than one record and the date are different, select only one with the max date. Also, this group, there could be more than one record with the "max date".

how can I accomplish this? thanks.
uid	name	date
1	name1	1/1/2011
2	name2	2/1/2011
2	name2	2/1/2011
3	name3	3/1/2011
3	name3	3/2/2011
3	name3	3/2/2011

Open in new window

Comment
Watch Question

Software Engineer
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
nice. thanks so much.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.