Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Latest price GROUP problem
Message
 
À
19/11/2013 15:04:29
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01588299
Message ID:
01588331
Vues:
43
>Now: How about when the data is in 2 files, FooA and FooB and the latest date could be in either. Could you do this in one SQL statement with UNION? How?

:-)
Select Foo.Item, Foo.date, MAX(Foo.Price) AS Foo.Price ;
from (SELECT * FROM FooA;
      UNION ALL;
      SELECT * FROM FooB) Foo;
INNER JOIN (SELECT Item, MAX(Date) AS Date;
            FROM (SELECT * FROM FooA;
                  UNION ALL;
                  SELECT * FROM FooB) Foo;
            GROUP BY Item) Foo1;
      ON Foo.Item = Foo1.Item AND Foo.Date = Foo1.Date;
GROUP BY Foo.Item, Foo.date;
into cursor boo
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform