Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Cobol > Re: ProCobol Ou...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 9 of 15 Topic 4108 of 4195
Post > Topic >>

Re: ProCobol Outer join

by "Pete Dashwood" <dashwood@[EMAIL PROTECTED] > May 9, 2008 at 03:09 PM

"Robert" <no@[EMAIL PROTECTED]
> wrote in message 
news:lj3724d5ohrvdm3vvl91gq43hk154hsa85@[EMAIL PROTECTED]
> On Thu, 8 May 2008 06:58:32 -0700 (PDT), jeff <jmoore207@[EMAIL PROTECTED]
>
wrote:
>
>>I am having a problem with a left outer join when I add conditionals.
>>
>>Select
>>        A. vehicle,
>>        B.Vehicle,
>>        B.acct,
>>        B.MOYR,
>>        B.Trancode
>> from  Table1 A, Table2 B
>> where A.vehicle=B.vehicle(+)
>>  and   B.acct='1234'
>>  and   B.MOYR = '0502'
>>  and  B.trancode='80'
>>  order by a.vehicle
>>
>>I need all a.vehicles for all vehicles to come back in the cursor
>>regardless. Any ideas?
>
> select *  from
> ( (select a.vehicle, b.vehicle as b_vehicle,  b.acct, b.MOYR, b.trancode
>  from table1 a, table2 b
>  where a.vehicle = b.vehicle
>      and b.acct='1234'
>      and b.MOYR = '0502'
>      and b.trancode='80'
> ) matches
> union
> select vehicle, null, null, null, null
>  from table1 a
>  where vehicle not in (select vehicle from matches)
> order by vehicle
> )
>
> There is a simpler way using DISTINCT, which applies to all columns 
> FOLLOWING the word
> distinct.
>
> select vehicle, b_vehicle, acct, MOYR, trancode  from
> (select b_vehicle, acct, MOYR, trancode, DISTINCT vehicle from
> (select a.vehicle, b.vehicle as b_vehicle,  b.acct, b.MOYR, b.trancode, 
> '1' as source
>   from table1 a, table2 b
>   where a.vehicle = b.vehicle
>      and b.acct='1234'
>      and b.MOYR = '0502'
>      and b.trancode='80'
>  union
>  select vehicle, null, null, null, null, '2' as source
>   from table1
>  order by vehicle, source
> )
> )

Very impressive, Robert.

Thanks for posting this. I, for one, learned something.

Pete.
-- 
"I used to write COBOL...now I can do anything."
 




 15 Posts in Topic:
ProCobol Outer join
jeff <jmoore207@[EMAIL  2008-05-08 06:58:32 
Re: ProCobol Outer join
"Michael Mattias&quo  2008-05-08 09:24:01 
Re: ProCobol Outer join
jeff <jmoore207@[EMAIL  2008-05-08 07:40:38 
Re: ProCobol Outer join
Robert Jones <rjones0@  2008-05-08 10:54:52 
Re: ProCobol Outer join
jeff <jmoore207@[EMAIL  2008-05-08 11:01:48 
Re: ProCobol Outer join
Robert Jones <rjones0@  2008-05-08 13:56:21 
Re: ProCobol Outer join
Robert <no@[EMAIL PROT  2008-05-08 18:36:04 
Re: ProCobol Outer join
Robert <no@[EMAIL PROT  2008-05-08 20:40:41 
Re: ProCobol Outer join
"Pete Dashwood"  2008-05-09 15:09:26 
Re: ProCobol Outer join
Robert <no@[EMAIL PROT  2008-05-08 20:48:29 
Re: ProCobol Outer join
"Pete Dashwood"  2008-05-09 15:11:11 
Re: ProCobol Outer join
Robert <no@[EMAIL PROT  2008-05-08 22:55:34 
Re: ProCobol Outer join
"Michael Mattias&quo  2008-05-09 08:17:58 
Re: ProCobol Outer join
"Pete Dashwood"  2008-05-10 12:57:31 
Re: ProCobol Outer join
Robert <no@[EMAIL PROT  2008-05-08 22:25:10 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 22:02:14 CDT 2008.