Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do I optimize this query?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00803505
Message ID:
00803577
Vues:
9
>I am trying to find a way to optimize the following query. what I am trying to do is find the last value greater than zero inserted into table. My id is primary key. The unemp_ins_pct and id fields in payroll table are indexed. When I run this query I get a bar saying running query on screen. There has got be a quicker way to get the results I want. Here is the query:
>
>
>select unemp_ins_pct ;
>	from payroll_tbl ;
>	where unemp_ins_pct # 0 ;
>	into array a__gen40 ;
>	order by payroll_tbl.id
>
>	If vartype(a__gen40) # 'U' and vartype(a__gen40) # 'L'			
>		b1 = alen(a__gen40)
>		if b1 = 1
>			.q1 = (a__gen40(1,1))	&&latest unemp_ins_pct
>		else
>			.q1 = (a__gen40(b1,1))	&&latest unemp_ins_pct
>		endif
>	else
>		.q1 = 0	&&latest unemp_ins_pct not found
>	endif
>	release a__gen40
>
Try
Select Top 1 unemp_ins_pct ;
	From payroll_tbl ;
	Into Array a__gen40 ;
	Where unemp_ins_pct > 0 ;
	Order By payroll_tbl.id Desc
censored.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform