Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Select question
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00793758
Message ID:
00794337
Vues:
22
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform