Problem with left outer-join

nborshukov

New Member
GUI
DB Server: 8.2a
Client: 9.0a
OS: WinXP

I have a problem with execution of browser's query with left outer-join. Here is the open query statement:

define buffer PrevOrder for Order.

open query br-1 for each customer no-lock,
last order where Order.Cust-Num = Customer.Cust-Num,
last PrevOrder left outer-join where PrevOrder.Cust-Num = Order.Cust-Num and
PrevOrder.order-date < Order.order-date
by Customer.Name.

Display fields:
customer.name
order.Order-date
PrevOrder.Order-date

This query must display all the customers, which have AT LEAST one order, and the previous order of the cistomer.
But in fact it displays ALL the cistomers, even they have no orders.
Does anybody knows where is the problem???
By the way, client 9.1d works correctly...
 

4GLNewbie

Member
Maybe if done in two steps it will become correct?
Do a first for each on the join between customers and orders, and then if avaiable you do the second join..

But be careful, if you tell the program to show a PrevOrder when it has not been finded, i think you will get an error or unexpected results.

In a SQL statement i would have used parenthesis to solve it. In progress I dont know if it can be done.
 
Top