Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: SQL HELP - SOLVED!!!

RE: SQL HELP - SOLVED!!!

From: Viktor <stant_98_at_yahoo.com>
Date: Wed, 27 Aug 2003 07:19:25 -0800
Message-ID: <F001.005CD7C9.20030827071925@fatcity.com>


Thanks to ALL for your help on this!  

As always your advice is greatly appreciated!  

Viktor

"Jamadagni, Rajendra" <Rajendra.Jamadagni_at_espn.com> wrote: Try something like ...    

select id, col_1, col_2,sum(web_c),sum(other_c) from
(select id, to_char(received_date,'YYYY-MM') col_1,yr||seq_no||ck col_2,

       case when seq_no > 4000 then 1 else 0 end web_c,
       case when seq_no <= 4000 then 1 else 0 end other_c 
  from t
 where received_date between your_start_date and your_end_date) group by id, col_1, col_2
/  

Raj



Rajendra dot Jamadagni at nospamespn dot com All Views expressed in this email are strictly personal. QOTD: Any clod can have facts, having an opinion is an art ! -----Original Message-----
Sent: Tuesday, August 26, 2003 5:00 PM
To: Multiple recipients of list ORACLE-L

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********************************************************************This e-mail message is confidential, intended only for the named recipient(s) above and may contain information that is privileged, attorney work product or exempt from disclosure under applicable law. If you have received this message in error, or are not the named recipient(s), please immediately notify corporate MIS at (860) 766-2000 and delete this e-mail message from your computer, Thank you.*********************************************************************2


---------------------------------

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Viktor
  INET: stant_98_at_yahoo.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L

(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).
Received on Wed Aug 27 2003 - 10:19:25 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US