Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: SQL need help
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
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).
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
![]() |
![]() |