Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Group By....Having

Posted on 1998-08-21
4
Medium Priority
?
162 Views
Last Modified: 2010-03-19
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
0
Comment
Question by:anilkumarv
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
connex earned 50 total points
ID: 1089679
SELECT CODE,NAME,MAX(date)
FROM TABLE
GROUP BY CODE,NAME

Should do it

0
 
LVL 5

Expert Comment

by:mayhew
ID: 1089680
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.   :)
0
 

Author Comment

by:anilkumarv
ID: 1089681
Thanx Mayhew
Your comment solved my probelm.
0
 
LVL 5

Expert Comment

by:mayhew
ID: 1089682
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.
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question