Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is there a pure SQL way without Scan ?
Message
De
08/08/2006 20:38:37
 
 
À
08/08/2006 18:37:05
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01143938
Message ID:
01143960
Vues:
8
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform