Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Need to get count of repeated values in a table

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Need to get count of repeated values in a table
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    Post subject:
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    Post subject: Reply to: Need to get count of repeated values in a table
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
No new posts Table(Unicode(Graphic) table) loading... muralikrishnan_new DB2 0 Thu Oct 05, 2017 5:10 pm
No new posts Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm
No new posts Insert a Row_number into table useit DB2 2 Tue Sep 19, 2017 1:07 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us