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

How to count number of rows in table


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

New User


Joined: 06 May 2008
Posts: 96
Location: Delhi

PostPosted: Fri May 29, 2009 9:42 am
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: 355
Location: New York

PostPosted: Fri May 29, 2009 10:35 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
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 Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts To find whether record count are true... DFSORT/ICETOOL 6
Search our Forums:

Back to Top