MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how to retrieve tot count in COUNT col when mo & ye are

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
satya_reddy
Beginner


Joined: 21 Sep 2004
Posts: 16
Topics: 3

PostPosted: Tue Sep 21, 2004 10:41 pm    Post subject: how to retrieve tot count in COUNT col when mo & ye are Reply with quote

My query is as
Code:

SELECT ITSSADLP_ID_RACF, ITSSADLP_REG_TAB                     
     , COUNT (ITSSADLP_ID_RACF)                               
     , YEAR (ITSSADLP_STAT_TS)                               
     , MONTH (ITSSADLP_STAT_TS)                               
FROM SCITST.ITSSADLP                                         
WHERE ITSSADLP_ID_RACF = 'S027059'                           
GROUP BY ITSSADLP_ID_RACF, ITSSADLP_REG_TAB, ITSSADLP_STAT_TS
ORDER BY ITSSADLP_ID_RACF, ITSSADLP_REG_TAB                   

the result is as
Code:

ITSSADLP  ITSSADLP                                       
   ID       REG                                         
  RACF      TAB            COL1         COL2         COL3
--------  --------  -----------  -----------  -----------
D027059   ST                  6         2004            4
D027059   ST                  5         2004            4
D027059   ST                  5         2004            5
D027059   ST                  6         2004            5
D027059   ST                  4         2004            6

how I need is as
Code:

ITSSADLP  ITSSADLP                                       
   ID          REG                                         
  RACF      TAB            COL1         COL2         COL3
--------  --------  -----------  -----------  -----------
D027059   ST                  11        2004            4
D027059   ST                  11        2004            5
D027059   ST                   4        2004            6

i.e when month and year matchs, I need to have the count of RACF occurences. Can you help me in fine tuning the query.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Sep 22, 2004 8:51 am    Post subject: Reply with quote

Satya_reddy,

Try this sql

Code:

SELECT C.ID
      ,C.REG
      ,SUM(C.CNT)
      ,C.YR
      ,C.MN
  FROM (SELECT ITSSADLP_ID_RACF         AS ID
              ,ITSSADLP_REG_TAB         AS REG                     
              ,COUNT (ITSSADLP_ID_RACF) AS CNT
              ,YEAR  (ITSSADLP_STAT_TS) AS YR
              ,MONTH (ITSSADLP_STAT_TS) AS MN
          FROM SCITST.ITSSADLP                                         
         WHERE ITSSADLP_ID_RACF = 'S027059'                           
         GROUP BY ITSSADLP_ID_RACF, ITSSADLP_REG_TAB, ITSSADLP_STAT_TS ) C
 GROUP BY C.ID
         ,C.REG
         ,C.YR
         ,C.MN
 ORDER BY C.ID
         ,C.REG
;


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
satya_reddy
Beginner


Joined: 21 Sep 2004
Posts: 16
Topics: 3

PostPosted: Wed Sep 22, 2004 11:46 am    Post subject: Reply with quote

Thanks Kolusu, this helped me.

Satya...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group