Thread: Wisegroup
View Single Post
  #2 (permalink)  
Old 03-30-09, 11:11
JarlH JarlH is offline
Registered User
 
Join Date: Dec 2008
Location: At work...
Posts: 68
Some (untested) alternatives:

SELECT "group", "date", MAX(price)
FROM thistable
WHERE ("group", "date") IN (SELECT "group", MAX("date") FROM thistable GROUP BY "group")
GROUP BY "group", "date"


The following feature outside Core SQL-99 is used:
F641, "Row and table constructors"



SELECT "group", "date", MAX(price)
FROM thistable AS outmst
WHERE "date" = (SELECT MAX("date") FROM thistable WHERE "group" = outmst."group")
GROUP BY "group", "date"


Core SQL-99.


Note that both GROUP and DATE are reserved words in ANSI/ISO SQL. It's a good idea to double quote those column names to avoid future problems.
Reply With Quote