I'm not sure I entirely understand the result you are trying to achieve.

Perhaps this will help

select received_date, msno, sum(count_web), hardcopy
from (
select id ,
         to_char(received_date, 'YYYY-mm') received_date,
         id||yr||seq_no||ck MSNO
         CASE WHEN seq_no > 4000 then count(seq_no) ELSE 0 end Count_WEB,
         CASE WHEN seq_no <=4000 then count(seq_no) ELSE 0   END  HARDCOPY

 from t
where received_date between '01/01/2003' and '12/31/2003'
group by id,
  to_char(received_date, 'YYYY-mm'),

   sequence_no,
  id||yr||seq_no||ck

)
group by received_date, msno, hardcopy
/




Viktor <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED]

 08/26/2003 01:59 PM
 Please respond to ORACLE-L

       
        To:        Multiple recipients of list ORACLE-L <[EMAIL PROTECTED]>
        cc:        
        Subject:        SQL HELP!!!



Hello,
 
I was wondering if someone can help me with a report. I am stuck figuring out what I can do to complete it. Here is what I need to do:
 
for a given date range, i..e. start_date - end_date ('01/01/2003',  '12/31/2003'), I need to count all "web", and "non-web" records. If seq_no > 4000, then it's web, otherwise non-web. seq_no is not unique. So it's like 2 different where claused in a single select. Could I somehow use CASE or decode to accomplish this. Here is what I am trying to do in select:
 
select id ,
         to_char(received_date, 'YYYY-mm'),
         id||yr||seq_no||ck MSNO
         CASE WHEN seq_no > 4000 then count(seq_no) ELSE 0 end Count_WEB,
         CASE WHEN seq_no <=4000 then count(seq_no) ELSE 0   END  HARDCOPY

 from t
where received_date between '01/01/2003' and '12/31/2003'
group by id,
  to_char(received_date, 'YYYY-mm'),

   sequence_no,
  id||yr||seq_no||ck

/
 
AR 2003-01 AR030023T         0              1
AR 2003-01 AR0200302         0              1
AR 2003-01 AR020047K         0              1
AR 2003-01 AR020077N         0              1

 
I would like to show Year-Month once and count all instances of  id||yr||seq_no||ck (primary_key) for that Year-Month, but not to break on it, and unfortunaley it won't let me do it without grouping on seq_no
 
Please advise!!!
 
Any help is greatly appreciated!
 
 


Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

Reply via email to