Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using a field from derived table in Where issue
Message
From
17/08/2011 16:37:53
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01521189
Message ID:
01521199
Views:
43
>Hi,
>
>I can't seem to understand how to deal with the following issue.
>
>I have a SQL Select that uses derived table that creates a column, e.g. TOT_QTY. If there are no records in the LEFT JOIN (derived table) the value set to TOT_QTY is null. So in the SQL Select I use NVL( TOT_QTY, 0 ). And when I look at the resulting query I see that the records from the derived table are included with the value assigned to TOT_QTY as 0. So far so good. But if I include this column name in the WHERE clause (e.g. WHERE TOT_QTY > 0) none of the records are included in the query. It looks like the WHERE always uses the NULL value of the TOT_QTY and not the one that has been "processed" by NVL(). I hope my explanation is clear. What can I do to make the WHERE work in this case? TIA.

Can you move the condition into the HAVING clause?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform