Advertisement

06.30.2005 at 08:26PM PDT, ID: 21477165
[x]
Attachment Details

Select unique records from a table

Asked by gnoon in MS SQL Server

Tags: unique, select, records

I have a table called 'Users' with the following structure and data

Code     Name      EFFECTIVE_DATE (dd/mm/yyyy)
=====================
h1        Tommy    1/5/2005
h2        Alex         1/6/2005
h2        Alex         15/6/2005

I need *a query statement* that produces the following output

Code     Name      EFFECTIVE_DATE (dd/mm/yyyy)
=====================
h1        Tommy    1/5/2005
h2        Alex         15/6/2005

* The key is "get a record that has max value of EFFECTIVE_DATE, if duplicate"

I've thought of MAX(EFFECTIVE_DATE) can be used, but I don't know how to use it.

Regards,
Noon
Start Free Trial
[+][-]06.30.2005 at 08:28PM PDT, ID: 14344408

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: MS SQL Server
Tags: unique, select, records
Sign Up Now!
Solution Provided By: adilkhan
Participating Experts: 1
Solution Grade: A
 
 
[+][-]06.30.2005 at 08:40PM PDT, ID: 14344444

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32