Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Received / Outgoing Product
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01210081
Message ID:
01212300
Views:
13
Cecil,

See the changes inside.

1) You don't need to create the extra fields in your inner selects (and, as I said, you may not need inner join to customers table in inner selects).

UPDATE. Looks like this point was already covered in Sergey's message which I didn't see when I responded.

2) You should either use CAST function or specify as many 0s as you need in NVL to create a field of the appropriate length.

>I tried the code your ecommended and it seems to work very well except my QtyIn ends up with an Asterisk:
>
>	*	
>	SELECT ;
>			cs.customer, ;
>			NVL(si1.QtyIn, 000000) As QtyIn, ;
>			NVL(so1.QtyOut, 000000) As QtyOut, ;
>			NVL(si1.QtyIn, 000000) - NVL(so1.QtyOut,00000) As QtyDiff ;
>		FROM ;
>			customer cs ;
>		LEFT JOIN ;
>			(;
>			SELECT ;
>					si.Cust, ;
>					cs.customer, ;
>					SUM(si.StandsIn) As QtyIn ;
>				FROM ;
>					Customer cs ;
>				INNER JOIN StandsIn si ;
>				ON cs.custno = si.cust ;
>				WHERE ;
>					BETWEEN(DateIn, .dFrom, .dThru) ;
>				GROUP BY ;
>					si.cust, ;
>					cs.customer ;
>				ORDER BY ;
>					cs.customer ;
>			) ;
>			si1 ON si1.cust = cs.custno ;
>		LEFT JOIN ;
>			(;
>			SELECT ;
>					so.Cust, ;
>					cs.customer, ;
>					SUM(so.SerialCnt) As QtyOut ;
>				FROM ;
>					customer cs ;
>				INNER JOIN Stands_Out so ;
>				ON so.cust = cs.custno ;
>				WHERE ;
>					BETWEEN(date, lcStartDate, lcEndDate) ;
>				GROUP BY ;
>					so.cust, ;
>					cs.customer ;
>				ORDER BY ;
>					cs.customer ;
>			) ;
>			so1 ON so1.cust = cs.custno ;
>		INTO CURSOR final
>
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform