From: Peter Brawley Date: February 13 2006 3:53pm Subject: Re: selecting min, max List-Archive: http://lists.mysql.com/mysql/194855 Message-Id: <43F0AB87.6000808@earthlink.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit Octavian, >I need to extract a list which the following values from this table, for >each hour (in date_time field): >- symbol >- min(price) >- max(price) >- price where date_time is the earliest for that certain hour. >- price where the date_time is the last from that hour. >- The sum of volume from that hour. Groupwise aggregates again. Very often required & asked about. See http://www.artfulsoftware.com/queries.php#18 and http://www.artfulsoftware.com/queries.php#19 for two typical answers. PB Octavian Rasnita wrote: > Hi, > > I have a table with the following fields: > > symbol, date_time, price, volume > > I need to extract a list which the following values from this table, for > each hour (in date_time field): > > - symbol > - min(price) > - max(price) > - price where date_time is the earliest for that certain hour. > - price where the date_time is the last from that hour. > - The sum of volume from that hour. > > I have tried to get the list of symbols, then get each hourly period and > calculate those 6 values for each period, but there are many symbols and > very many periods, and it takes very very much time. > > Is there a more intelligent way of getting those values in another way than > symbol by symbol and period by period? > > Thank you very much. > > Teddy > > > -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.375 / Virus Database: 267.15.6/258 - Release Date: 2/13/2006