Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Query
Message
From
12/08/2003 11:42:25
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00819247
Message ID:
00819402
Views:
15
Hi Ravi,
* DISTINCT AND GROUP ARE NOT OPTIMIZABLE
SELECT DISTINCT Deptt FROM EmpSalary GROUP BY 1 INTO CURSOR TEMP

* INDEX on Deptt  TAG dtag  && now index is usefull

SELECT TOP 2 Emp_ID ,Emp_Name ,Salary ,Deptt FROM EmpSalary;
  WHERE _TALLY>0 AND Deptt=TEMP.Deptt ORDER BY 3 DESC;
  INTO CURSOR Result READWRITE

SELECT TEMP
SKIP SIGN(_TALLY)
SCAN REST
	INSERT INTO Result;
	SELECT TOP 2 Emp_ID ,Emp_Name ,Salary ,Deptt FROM EmpSalary;
           WHERE Deptt=TEMP.Deptt ORDER BY 3 DESC
ENDSCAN
USE
SELECT Result
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform