Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Query question
Message
De
22/03/2015 06:25:21
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MySQL
Application:
Web
Divers
Thread ID:
01617030
Message ID:
01617082
Vues:
42
>>Hi Hugo,
>>
>>and now - generic for n items ....
>>
>>w/o macro or the like
>
>Good question. I see the errors of my ways... In that case I would use Rich's version, I think, cannot give it much thought now though.
>
>
>create table #Customers (CustomerID int, CustomerName varchar(50))
>create table #Products (ProductID int, ProductName varchar(50), Price Money)
>create table #Sales (ProductID int, CustomerID int, Quantity int)
>create table #List (ProductID int)
>
>insert into #Customers (CustomerID, CustomerName) values (1, 'Robert'), (2, 'James'), (3, 'Anderson')
>insert into #Products (ProductID, ProductName, Price) values (1, 'Apple', 1), (2, 'Orange', 5.3), (3, 'Grapes', 2)
>insert into #Sales (ProductID, CustomerID, Quantity) values (1, 1, 1), (1, 2, 3), (2, 1, 2), (3, 1, 5), (2, 2, 2), (1, 1, 1)
>insert into #List (ProductID) values (1), (3)
>
>select		Cust.CustomerId, 
>		Cust.CustomerName
>	from	#Customers Cust
>	inner	join #Sales S On Cust.CustomerId = S.CustomerId
>	where	S.ProductID IN (select ProductID from #List)
>	group	by Cust.CustomerID, Cust.CustomerName
>	having	count(distinct(ProductID)) = (select count(*) from #List)
>
>drop table #Customers
>drop table #Products
>drop table #Sales
>drop table #List
>
In genereal I think we give the wrong answer anyway

He uses MS SQL Server. I think this could be done much better there. But I can't :)
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform