Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Select question
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00793758
Message ID:
00794337
Views:
24
Hi Dmitry,

If you need to select only received and used parts, you would need INNER JOIN. Fabio's select should work, though I would put date condition in the WHERE clause.

>Fabio,
>I will try your SQL select. But I thought I tried it pretty much as you have it and I was getting much of duplication. The only thing I was not using is aliases for the tables. Maybe this make a difference. I will try it.
>
>Thank you for your help.
>
>>Hi Dmitry,
>>
>>
>>SELECT P.partno, SUM(U.qUsed) totUse, SUM(R.qReceived) totRec FROM parts P
>>LEFT JOIN partsUses U;
>> ON U.dateUsed BEETWEN m.dateInit AND m.dateEnd AND U.partNo=P.partNo;
>>LEFT JOIN partsReceived R;
>> ON R.dateReceived BEETWEN m.dateInit AND m.dateEnd AND R.partNo=P.partNo;
>>GROUP BY 1; && result are in order
>>INTO CURSOR result
>>
>>
>>If you want remove parts not moved:
>>
>>
>>SELECT P.partno, SUM(U.qUsed) totUse, SUM(R.qReceived) totRec FROM parts P
>>JOIN partsUses U;
>> ON U.dateUsed BEETWEN m.dateInit AND m.dateEnd AND U.partNo=P.partNo;
>>JOIN partsReceived R;
>> ON R.dateReceived BEETWEN m.dateInit AND m.dateEnd AND R.partNo=P.partNo;
>>GROUP BY 1; && result are in order
>>INTO CURSOR result
>>
>>
>>Attention: No put DATE() on SELECT command !
>>
>>Fabio
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform