Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: bad sql code?
Try this:
Select ord.ORDER_ID
, min(ord.REFERENCE_NUM) , min(ord.ISSUED_DATE) , sum(item.UNIT_PRICE * item.QUANTITY) , min(ord.CUSTOMER_PO_NUMBER ) , min(org.NAME||DECODE(bdem.REFERENCE_NUM, '','' ,' [') || bdem.REFERENCE_NUM||DECODE(bdem.REFERENCE_NUM,
'',''
,']'))
from ORDERS ord , ORDER_ITEM item , BUS_PARTY_ROLE role , ORGANIZATION org , BP_DEMOGRAPHICS bdem where ord.TYPE = 'INVOICE' and ord.RECEIVED_BY_EDI = 'Y' and ord.ORDER_ID = item.ORDER_ID and ord.RESELLER_ID = role.BUS_PARTY_ROLE_ID(+) and item.ACCOUNT_ID = 0 /* I am not sure if you want accounts that are = 0, if not do < 0 */ and role.BUS_PARTY_ID = org.BUS_PARTY_ID(+) and role.BUS_PARTY_ROLE_ID = bdem.BUS_PARTY_ROLE_ID(+)group by ord.ORDER_ID
I hope I understood your query correctly if not run EXPLAIN PLAN or better set tracing on and user TKPROF
Good luck!
Vitaliy Mogilevskiy
Get free DBA Scripts @http://home.earthlink.net/~vit100gain/index.html
David Spaisman wrote:
> Hello:
>
>
>
>> ,min(ord.ISSUED_DATE)
> Select ord.ORDER_ID
> , min(ord.REFERENCE_NUM)
![]() |
![]() |