Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Summing by location
Message
From
27/07/1999 13:09:15
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00246115
Message ID:
00246721
Views:
16
You must have another field in the InvOnHand table to specify the location. Try this:
SELECT INMAST.FPARTNO,  Sum(INONHD.FONHND);
	FROM INONHD RIGHT JOIN INMAST;
	ON INONHD.FPARTNO=INMAST.FPARTNO;
	WHERE &LCWHERE;
       GROUP BY INMAST.FPARTNO;
	INTO CURSOR TMP1
The IIF() won't work to acheive what you want, but in other cases it can be used in the SELECT-SQL. The syntax should be:
SELECT IIF(EMPTY(INONHD.FONHND), 0, INONHD.FONHND) AS FONHND
BTW, is INONHD.FONHND as character field? If so, you would need to add a Val() to the Sum() in the SELECT.

HTH

>The structure: InvMast is the Master table with the description, part number, stock re-order level, etc. InvOnHand is a table with only the part number, and the quantity on hand.
>In the InvOnHand table it creates a record for each part number in each location(ie.--if part 011 has 2500 in location 01 and 32 in location 02 then there will be 2 records, if however there is 3200 in location 02 and 0 in location 01 there will be only 1 record for the location that has something on hand).
>
>Thus, I can assume that when there is no record in the onhand table, that part number has 0 on hand in that location. My question is: How do I test for this within the SQL statement?
>
>Here again is the statement I have thus far:
>
SELECT INMAST.FPARTNO, INONHD.FONHND ;
>	FROM INONHD RIGHT JOIN INMAST;
>	ON INONHD.FPARTNO=INMAST.FPARTNO;
>	WHERE &LCWHERE;
>	INTO CURSOR TMP1
>LCWHERE is concatenated according to other conditions within the form...is there a way to put like an IIF() like this?
>
SELECT INMAST.FPARTNO,IIF(EMPTY(INONHD.FONHND),'0' AS FONHND,INONHD.FONHND)...
>I've tried the above and it keeps giving me an error when the SQL is executed that it needs a )....got any ideas?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform