Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calculating variances
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP1
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01059566
Message ID:
01059572
Views:
11
This message has been marked as the solution to the initial question of the thread.
>Hi Borislav
>
>Yes I could have it that way. The only way of determining the differences is be finding whether the colour we have added i.e. White is contained in the system colour MS - WH (WHITE). If so and there is a variance then print it.
>
>But there will be from time to time a colour we have added but no system colour been added.
>
>Thanks

Try this:
CREATE CURSOR cTest (Product1 C(10), Colour C(15), Qty I)
INSERT INTO cTest VALUES ([JKT001],[Black],20)
INSERT INTO cTest VALUES ([JKT001],[MS - YO(BLACK)],20)

INSERT INTO cTest VALUES ([JKT001],[Blue],10)
INSERT INTO cTest VALUES ([JKT001],[MS - BL(BLUE)],20)

INSERT INTO cTest VALUES ([JKT002],[Beige],10)
INSERT INTO cTest VALUES ([JKT002],[MS - BE(BEIGE)],15)

INSERT INTO cTest VALUES ([JKT003],[Beige],10)

SELECT Product1, SUM(Qty) AS Qty, Colour;
       FROM cTest;
       WHERE LEFT(Colour,2) # [MS];
       GROUP BY Product1, Colour;
       INTO CURSOR cTest1

SELECT Product1, SUM(Qty) AS Qty, Colour;
       FROM cTest;
       WHERE LEFT(Colour,2) == [MS];
       GROUP BY Product1, Colour;
       INTO CURSOR cTest2
       
SELECT cTest1.Product1, (NVL(cTest2.Qty,0)-cTest1.Qty) AS Variance;
       FROM cTest1;
       LEFT JOIN cTest2 ON cTest1.Product1 == cTest2.Product1 AND [(]+UPPER(ALLTRIM(cTest1.Colour))+[)] $ cTest2.Colour;
       HAVING Variance # 0;
       INTO CURSOR cTest3
BROW
I don't know what to do when you didn't have a System color.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform