IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

SQL Query to select the name and no.of occurrence


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
arindambanerjee

New User


Joined: 30 Jun 2007
Posts: 39
Location: India

PostPosted: Sat Jul 11, 2009 7:49 pm
Reply with quote

Hi All,

I have a TABLE with the following structures:
T1(table name).

NAME Date
A 05/10/1998
B 05/05/2003
B 07/12/2008
A 09/07/2009
C 03/11/1994
A 13/10/1997
C 11/11/2008
My output required is:
A 3 09/07/2009
B 2 07/12/2008
C 2 11/11/2008
I.e. I need the name, no.of occurrence and the latest date associated with the Names.

Can we discuss this SQL query?
Back to top
View user's profile Send private message
bhairon singh rathore

New User


Joined: 19 Jun 2008
Posts: 91
Location: banglore

PostPosted: Sun Jul 12, 2009 2:40 am
Reply with quote

Select Name,count(*) as count,Max(Date) from TABLE
group by Name
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts SELECT from data change table DB2 5
Search our Forums:

Back to Top