Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Troublesome SQL construction
Message
From
20/12/2006 12:02:34
 
 
To
19/12/2006 18:37:58
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01179041
Message ID:
01179245
Views:
9
>>So far, my results have either wound up with 3 Customers(cutting out 2 and 5) or 8 Customers because of the duplicates. I know this shouldn't be that hard, but I'm not seeing what I missed.
>
>
select t1.customer, t2.date, t3.size ;
> from customer t1 ;
>  left join orders t2 on t1.custID = t2.custID ;
>     and t2.date = (select max(date) from orders o1 where o1.cust_id = t2.custid ) ;
>  left join lookup t3 on t2.amount = t3.amount
Cetin

When I tried it in this format, I got the error 'SQL: Subquery nesting is too deep.' I moved it to a WHERE clause and essentially got Sergey's answer, except his gave the error 'SQL expression is too complex.' In both of them, the MAX(date) is excluding the blank records, which I need to keep.

After a night's sleep, a fresh look at the problem, I broke it out into two queries.
Previous
Reply
Map
View

Click here to load this message in the networking platform