Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do I optimize this query?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00803505
Message ID:
00803577
Views:
8
>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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform