Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Complex SQL Select
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00712719
Message ID:
00712781
Vues:
9
Try
SELECT Purchase.Pearson, Purchase.Vehicle AS ExpensiveVehicle
	FROM Purchase
	WHERE Vehicle IN ( 
		SELECT TOP 1 Vehicle 
			FROM Vehicle  
			WHERE Vehicle.Pearson = Purchase.Pearson 
			OEDER BY Vehicle.Price DESC )
>I have the following two tables (Purchase and vehicle) in a SQL Server table. Is there a way to produce the result set where it will show the expensive vehilce purchased by a person, using a single SQL Select (it can be nested.) I can bring down both tables in to Fox using SPT and then programmatically find them. But the problem is if the Purchas table is so big, then it will be an issue.
>
>Important Note: This is not my school home work! I just created an example for a real problem I am having now.
>
>Purchase
>Person, Vechicle, PuchaseID
>A, Car, 1
>A, Truck, 2
>A, Bike, 3
>B, Bike, 4
>B, Jet, 5
>C, Truck, 6
>D, 4WD, 7
>D, Bike, 8
>
>Vehicle
>
>Vehicle, Price
>Car, 5000
>Bike, 100
>Truck, 7000
>Jet, 30000
>4WD,6000
>
>
>Expected Result Set
>
>Expensive Vehicle
>Person ExpensiveVehicle
>A Truck
>B Jet
>C Truck
>D 4WD
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform