Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is there a pure SQL way without Scan ?
Message
From
08/08/2006 20:38:37
 
 
To
08/08/2006 18:37:05
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01143938
Message ID:
01143960
Views:
10
Hi Fabio,

your solution works well in the example data I have created, but your SQL can create different results if working on other example data. Your version doesn't regard the "top 2", which is a kind of business logic in my case, but I have failed to adequately document in the example - my fault, especially when creating sample data lacking in this aspect also. If you use
FUNCTION data_create()
*-- create simple test data
CREATE CURSOR t_data	(cPeriod c(1), cSalesman c(1), nSales n(9,2))
FOR lnRun = 1 TO 2
	INSERT INTO t_data VALUES ("1", "A", 0500)
	INSERT INTO t_data VALUES ("1", "B", 0700)
	INSERT INTO t_data VALUES ("1", "C", 0900)
	INSERT INTO t_data VALUES ("1", "D", 0300)
	INSERT INTO t_data VALUES ("1", "E", 0400)
	INSERT INTO t_data VALUES ("2", "A", 0100)
	INSERT INTO t_data VALUES ("2", "B", 0700)
	INSERT INTO t_data VALUES ("2", "C", 0900)
	INSERT INTO t_data VALUES ("2", "D", 1300)
	INSERT INTO t_data VALUES ("2", "E", 1400)
	INSERT INTO t_data VALUES ("3", "A", 0100)
	INSERT INTO t_data VALUES ("3", "B", 1700)
	INSERT INTO t_data VALUES ("3", "C", 0900)
	INSERT INTO t_data VALUES ("3", "D", 0800)
	INSERT INTO t_data VALUES ("3", "E", 0200)
	INSERT INTO t_data VALUES ("4", "A", 1100)
	INSERT INTO t_data VALUES ("4", "B", 1107)
	INSERT INTO t_data VALUES ("4", "C", 1110)
	INSERT INTO t_data VALUES ("4", "D", 0300)
	INSERT INTO t_data VALUES ("4", "E", 0400)
next
your solution will select 3 records in period 4, whereas my code will select only (the top) 2 rows.

regards

thomas
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform