Oracle SQL Help

I wan’t to do a query that pulls out a value for a specific id but I want only to show the latest value.

Lets say the table is called Price, and the priceid is 10, I want to say select * from price where priceid = 10 but only show the lastest record for priceid 10

How do I do this?

I can do it in MySql but not Oracle.

Great thanks so much, that works!

i’ll bet you couldn’t do it correctly in mysql

here’s how you do it in either database system the right way –

SELECT something
     , anything
     , just_not_the_dreaded_evil_select_star 
  FROM ( SELECT priceid
              , MAX(datetimecolumn) AS latest
           FROM price
         GROUP
             BY priceid ) AS m
INNER
  JOIN price AS p
    ON p.priceid = m.priceid
   AND p.datetimecolumn = m.latest

“latest” has meaning only if there is a column which has values that you can take a MAX of

:cool:

oh, you only wanted this query for one price at a time?


SELECT something
     , anything
     , just_not_the_dreaded_evil_select_star 
  FROM ( SELECT MAX(datetimecolumn) AS latest
           FROM price
          WHERE priceid = 10 ) AS m
INNER
  JOIN price AS p
    ON p.datetimecolumn = m.latest
   AND p.priceid = 10

But where can I put the specific priceid value in the query?