Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Latest price GROUP problem
Message
 
To
18/11/2013 22:51:22
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01588299
Message ID:
01588302
Views:
59
>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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform