Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Latest price GROUP problem
Message
From
19/11/2013 15:27:06
 
 
To
19/11/2013 15:04:29
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:
01588331
Views:
44
>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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform