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 LOW VALUES as a KEY juares castro DB2 10 Sat Apr 07, 2018 1:06 am
No new posts Searching a table for the field name? socker_dad COBOL Programming 8 Sat Mar 31, 2018 2:57 am
No new posts Need inputs on DB2 tablespace/table r... ashek15 DB2 3 Sat Mar 24, 2018 11:49 pm
No new posts Creation of Datasets dynamically on t... Raghu M N DFSORT/ICETOOL 8 Fri Mar 16, 2018 12:56 am
No new posts Query to compare 2 values of 1 column... Poha Eater DB2 13 Fri Mar 09, 2018 10:45 am

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