Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Latest price GROUP problem
Message
 
À
18/11/2013 22:51:22
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:
01588302
Vues:
58
>Hi All:
>
>Consider
>
>
>Item#          Date        Price
>1111           2/3/04      111.22
>2222           2/3/05      111.22
>3333           2/3/06      111.22
>4444           2/3/07      111.22
>1111           2/3/08      222.22
>
>Select Item, max(date), Price ;
>from foo ;
>group by item ;
>into cursor boo
>
>
>I want the latest price, so this would be the result:
>
>
>Item#          Date        Price
>2222           2/3/05      111.22
>3333           2/3/06      111.22
>4444           2/3/07      111.22
>1111           2/3/08      222.22
>
>
>Problem is that VFP doesn't like this and generates an error GROUP BY clause missing. How do I solve this?
>
>Thanks,
>
>Yossi
Select Foo.Item, Foo.date, Foo.Price ;
from foo ;
INNER JOIN (SELECT Item, MAX(Date) AS Date;
            FROM Foo;
            GROUP BY Item) Foo1;
      ON Foo.Item = Foo1.Item AND Foo.Date = Foo1.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