Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Basic SQL problem
mikeyb wrote:
>> I'm a little confused. What really is "the most recent max price"??? >> from your query you get the MAX price independent of the date, so if >> that is the correct price, and you do not use the MAX date from the >> middle in-line view, then remove that view: >> >> select max(table.SO), table.price, table.date >> from table, >> ( >> select max(table.Price) price >> from table >> ) sq2 >> where sq2.price = table.price >> group by table.price, table.date >> >> Otherwise there is something in the requirement that I seem to be >> missing. >> >> Ed
WITH qb AS (SELECT MAX(price_ever) FROM <table_name>) ...
http://www.psoug.org
click on Morgan's Library
click on WITH clause
then complete by joining with qb and selecting ORDER_NUMBER and MAX(<sale_date>) WHERE rownum = 1.
-- Daniel A. Morgan University of Washington damorgan_at_x.washington.edu (replace x with u to respond) Puget Sound Oracle Users Group www.psoug.orgReceived on Mon Mar 12 2007 - 10:32:48 CDT