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 need help

RE: SQL need help

From: Jack van Zanen <JACK_at_QUANTSYSTEMS.NL>
Date: Thu, 03 Jul 2003 03:40:35 -0800
Message-ID: <F001.005C3354.20030703034035@fatcity.com>


select 'CustomerNo '||a.custno||' Total Order for this month = '||nvl(c.totalorder,0)
from

	all_customer a,
	(SELECT b.custno as custno, sum(b.totalorder) as totalorder 
	from orders b
	group by b.custno,to_char(b.dateorder,'mm')
	having to_char(b.dateorder,'mm')='06') c
where 	c.custno(+)=a.custno

Jack

-----Original Message-----
Sent: Thursday, July 03, 2003 11:06 AM
To: Multiple recipients of list ORACLE-L

Hi,

I have two tables

  1. ALL_CUSTOMER CustNo: 1 to 100 OtherDetail: bla bla bla
  2. ORDER CustNo TotalOrder DateOrder

I want to display like this

CustomerNo 1Total Order For This month = 101

or

CustomerNo 1 Total Order For This month = 0

My SQL statement is like this

SELECT a.custno, sum(b.total_order)
from all_customer a, order b
where b.custno (+) = a.custno
and to_char(dateorder, 'month') = 'JUNE' (PROBLEM is HERE) group by a.custno

When I run this statement for those customer that never order anything, my statement return No row returns

How to get something like this

             CustomerNo 1 Total Order For This month = 0

I tried this

        nvl(to_char(dateorder, 'month'), 'JUNE') = 'JUNE'

Thanks

Sinardy

--

Please see the official ORACLE-L FAQ: http://www.orafaq.net
--

Author: Sinardy Xing
  INET: SinardyXing_at_bkgcomsvc.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).
--

Please see the official ORACLE-L FAQ: http://www.orafaq.net
--

Author: Jack van Zanen
  INET: JACK_at_QUANTSYSTEMS.NL
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 Thu Jul 03 2003 - 06:40:35 CDT

Original text of this message

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