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:
00794136
Vues:
29
>>>Anybody can see if it could be done with one SQL select?
>>>
>>>TIA.
>>
>>I dont know for only 1 select.
>>But in 2 step:
>>
>>
>>* put all needed info in 1 cursor
>>SELECT parts.partno, 0000000000 as qtyused, 0000000000 as qtyrec FROM parts ;
>>	UNION(SELECT partno, qtyused, 000000000 as qtyrec FROM USEDPARTS) ;
>>	UNION(SELECT partno, 0000000000 as qtyused, qtyrec FROM RECEIVED) ;
>>	INTO CURSOR dummy
>>
>>* calculate the sum
>>SELECT partno,sum(qtyused),sum(qtyrec) from dummy GROUP BY 1
>>
>>
>
>This is pretty much how I thought it could be done, with two SQL selects. I wanted to be sure I am not missing some way to pull it all into one SQL select. Not to say that 1 SQL select would always make the query faster.
>
>Thank you for your help.

I am not sure that one complex query is faster than 2 or 3 chained queries.
I think I have read something (where?) that say the opposite.

With a couple of simple queries, its easy to build a rushmore optimizable select...
If we exchange an apple, we both get an apple.
But if we exchange an idea, we both get 2 ideas, cool...


Gérald Santerre
Independant programmer - internet or intranet stuff - always looking for contracts big or small :)
http://www.siteintranet.qc.ca
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform