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

Home -> Community -> Usenet -> c.d.o.misc -> Inline Query ?

Inline Query ?

From: Veronica Loria <message_4_u2001_at_yahoo.com>
Date: 14 Aug 2003 04:00:15 -0700
Message-ID: <3a03c004.0308140300.b1182d@posting.google.com>


Hello All,

     I wonder if you can help with a bit of fine tuned SQL, consider this query :

SELECT
   to_char(start_date, 'YYYYMM'),
   count(home_phone_number) "Valide Customers" FROM
  customer
WHERE
  home_phone_number NOT LIKE '%##%' AND
  (start_date between add_months(sysdate, -13) AND   add_months(sysdate, -1))
GROUP BY to_char(start_date, 'YYYYMM') ORDER BY to_char(start_date, 'YYYYMM');

This would print out -broken down by months for the last year- all of the records that have 'valid' phone numbers, as the following shows :

TO_CHA Valid Customers

------ ---------------------------------
200207                        12868
200208                        29031
200209                        27300
200210                        27612
200211                        26869
200212                        25156
200301                        22733
200302                        29401
200303                        40473
200304                        39232
200305                        42294
200306                        46869
200307                        26326


However, do you know of a way I can add to this query a 3rd column that would give me the total base records for each month ? so basically the 3rd column would contain the monthly totals of ALL records created (valid and invalid)... any suggestions for a solution are welcome, please write to my e-mail address if you can, thanks in advance.

Kind Regards,
Veronica
Message_4_u2001_at_yahoo.com Received on Thu Aug 14 2003 - 06:00:15 CDT

Original text of this message

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