Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Query runs twice instead of once
Message
De
22/09/2004 07:45:19
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
22/09/2004 06:43:28
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00944391
Message ID:
00944918
Vues:
14
>My dear Professor
>
>Your codes has solved my problem. But I could not understand them.
>If possible pleaes write some details about them specially about this select statment
>
>Set Ansi On
>Select Date,VOU_TYPE,Cnt(Distinct VOU_NO) As cntVouNo ;
>  FROM VOUCHERS ;
>  WHERE Date # {} And VOU_TYPE In ;
>  ('CP', 'CR', 'JV', 'PR', 'PS', 'SL', 'SS', 'SO', 'SD', 'SC') ;
>  Group By Date, VOU_TYPE ;
>  order By Date ;
>  INTO Cursor v1
>Set ansi off
>
>Please help again

Tariq,
This simply replaces your multiple:

select distinct ... from vouno ....
count to ...

statements. Instead of doing an SQL then count for each vou_type SQL collects counts for each VOU_TYPE at once. Result would look like:

dateX,CP,5
dateX,CR,3
...
dateY,CP,1
...

then scanning for a specific date (dateX for example) cntVouNo values are copied to corresponding memvar. Memvar name is in vou_type. ie:

store cntVouNo to ('m.'+trim(vou_type))

on dateX,CP,5 record stores 5 to m.CP.

The SQL is wrapped with SET ANSI to only collect values for CP,CR... but not for say CPX,CRY...

VOU_TYPE In ;
('CP', 'CR', 'JV', 'PR', 'PS', 'SL', 'SS', 'SO', 'SD', 'SC')

Without SET ANSI ON if you had CPY as vou_type it would be collected too (no harm maybe but no need OTOH).
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform