From: Peter Brawley Date: February 22 2006 4:21pm Subject: Re: selecting based on a max() condition List-Archive: http://lists.mysql.com/mysql/195062 Message-Id: <43FC8F6E.9080000@earthlink.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit 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