Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL select problem with order of LEFT JOIN
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 6 SP5
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01060396
Message ID:
01060399
Views:
12
This message has been marked as the solution to the initial question of the thread.
Make 0 constant the same size/format as the fields.
nvl(SUM(CHILD1.NUM_FIELD1),000000000000.00) AS TOT_NUM1, ;
nvl(SUM(CHILD2.NUM_FIELD2*CHILD2.NUM_FIELD3),000000000000.00) as TOT_NUM2, ;	
>Note that this message/problem I experience is with VFP 6 (because I don't know if it works differently in VFP 9)
>
>I have the following SQL Select (simplified)
>
>
>select MYTABLE1.FIELD1 as GROUP_ID, ;
>  COUNT(DISTINCT(MYTABLE1.ORDER_NO)) as NUM_ORDS, ;
>nvl(SUM(CHILD1.NUM_FIELD1),0) AS TOT_NUM1, ;
>nvl(SUM(CHILD2.NUM_FIELD2*CHILD2.NUM_FIELD3),0) as TOT_NUM2, ;	
>from MYTABLE1 ;
>LEFT JOIN CHILD1 ON MYTABLE1.ORDER_NO = CHILD1.ORDER_NO ;
>LEFT JOIN CHILD2 on MYTABLE1.ORDER_NO = CHILD2.ORDER_NO ; 	
>where MYTABLE1.ORD_DATE >= ctod("01/01/2002") and MYTABLE1.ORD_DATE <= ctod("12/31/2002")
>group by GROUP_ID
>
>
>The problem is that depending on the order of LEFT JOIN CHILD1 and LEFT JOIN CHILD2 I get asterisk (*) in either field TOT_NUM1 or TOT_NUM2.
>
>Can someone explain why it works that way and possibly how to avoid it?
>
>Thank you.
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform