Link to home
Start Free TrialLog in
Avatar of anilkumarv
anilkumarv

asked on

Group By....Having

I have the Data:

code   name     date
.........................
code1  namea    date1
code1  nameb    date2
code1  namec    date3
code2  namem    datex
code2  namen    datey
code2  nameo    datez

so on.........
I want result as

code1   name  max(date)
code2   name  max(date)


I want the details of each code,..... when Date is Max.

I have tried Group By with Having.
Anybody with sample code/syntax

Thanx
ASKER CERTIFIED SOLUTION
Avatar of connex
connex
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mayhew
mayhew

If you're trying to just get the rows that have the max date for each code, you might want to try:

select code, name, date from table a
where date=(select max(date) from table b
           where a.code = b.code)

BTW, that's not a typo.  It's a double reference to the same table.

Let us know if you're looking for something else.   :)
Avatar of anilkumarv

ASKER

Thanx Mayhew
Your comment solved my probelm.
Glad to be of service.

BTW, if you want to award points to a comment, you can reject a previous answer and ask the comment poster to repost as an answer.  That way you can award points to the person that helped you.

Just wanted to let you know.  :)

Again, I'm glad it's working for you.