Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to count number of rows in table

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
scorp_rahul23

New User


Joined: 06 May 2008
Posts: 90
Location: Chennai

PostPosted: Fri May 29, 2009 9:42 am    Post subject: How to count number of rows in table
Reply with quote

I have table

COL_NBR PRD_DT
=======================
abc 0001-01-01
def 0001-01-01
abc 2001-01-01
ghi 0001-01-01


I want to count number of rows present in this table where
count of COL_NBR is 1 only.

In output I need

COL_NBR PRD_DT
=======================
def 0001-01-01
ghi 0001-01-01

Please tell me how can I do this
Back to top
View user's profile Send private message

ksk

Active User


Joined: 08 Jun 2006
Posts: 356
Location: New York

PostPosted: Fri May 29, 2009 10:35 am    Post subject:
Reply with quote

you can try the following query.

Code:

SELECT COL_NBR,PRD_DT,COUNT(*) AS COUNT1   
FROM table
GROUP BY COL_NBR                     
HAVING COUNT(*) = 1;
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 DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
No new posts Row-Numbers of distinct rows? Auryn DB2 1 Thu Oct 20, 2016 4:38 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us