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

Need to get count of repeated values in a table


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

New User


Joined: 26 May 2007
Posts: 45
Location: Chennai

PostPosted: Sat Sep 13, 2008 1:28 am
Reply with quote

Hi Team ,

I have a DB2 table called sudent_info. I need to get the count of people with the same name.

Example : The table containing data as below

STU_NO STU_NAME
1 ---------- A
2 ---------- B
3 ---------- A
4 ---------- C
5 ---------- B
6 ---------- A


I need the result like

Name Count
A ------ 3
B ------ 2
C ------ 1

Can you please suggest.
Back to top
View user's profile Send private message
Suresh Ponnusamy

Active User


Joined: 22 Feb 2008
Posts: 107
Location: New York

PostPosted: Sat Sep 13, 2008 1:39 am
Reply with quote

Hi

Please try this

SELECT STU_NAME ,COUNT(STU_NAME)
FROM
STUDENT_INFO
GROUP BY STU_NAME
Back to top
View user's profile Send private message
aryanpa1

New User


Joined: 26 May 2007
Posts: 45
Location: Chennai

PostPosted: Sat Sep 13, 2008 1:59 am
Reply with quote

Thank you very much Suresh it worked.
Back to top
View user's profile Send private message
Suresh Ponnusamy

Active User


Joined: 22 Feb 2008
Posts: 107
Location: New York

PostPosted: Sat Sep 13, 2008 7:10 am
Reply with quote

Hi Pavan

You are welcome icon_smile.gif
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 INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Load new table with Old unload - DB2 DB2 6
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top