List:General Discussion« Previous MessageNext Message »
From:Peter Brawley Date:February 22 2006 4:21pm
Subject:Re: selecting based on a max() condition
View as plain text  
Octavian,

>I want to select the list of unique symbols and the corresponding price and
>last_update fields for each line where the last_update is equal to the
>last_update field for each symbol.

You're close! See the example at 
http://www.artfulsoftware.com/queries.php#18.

PB

-----

Octavian Rasnita wrote:
> Hi,
>
> I have a table with 3 relevant columns:
> symbol varchar(10) not null
> price decimal not null
> and
> last_update datetime not null
>
> I want to select the list of unique symbols and the corresponding price and
> last_update fields for each line where the last_update is equal to the
> last_update field for each symbol.
>
> I have tried without succes:
>
> select symbol, price, last_update from table where last_update =  (select
> max(last_update) from table);
>
> This gave me a single row. I have tried more complex queries that took a lot
> of time and I needed to break them with ^C.
>
> Thank you.
>
> Teddy
>
>
>   


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 268.0.0/266 - Release Date: 2/21/2006

Thread
selecting based on a max() conditionOctavian Rasnita22 Feb
  • Re: selecting based on a max() conditionPeter Brawley22 Feb