Re: Select a specified number items from a table
Posted in 1996
Topics: General Discussion
>>>>>>>>>> Perry's response to Charley Chen <<<<<<<<<< The easiest way is to construct a query with an order by descending on the column that contains the "latest", I'm assuming a date and/or time column, criteria and use a prepare/declare/open. Then use a fetch into in a for loop. ie... ###################################################################### function get_data() ###################################################################### # define myrec array[5] of decimal(18) let sqlStr = "select rate, update_time from my_rate_table ", "order by update_time descending" prepare stmt1 from sqlStr declare curs1 cursor for stmt1 open curs1 for x = 1 to 5 fetch curs1 into myrec[x] end for end function # get_data() > From: Charley Chen <cchen@transre.com> > Subject: Select a specified number items from a table > Date: Mon, 4 Mar 1996 15:08:58 GMT > To: informix-list@rmy.emory.edu > > Hi, > > I'm having a problem trying to select only a certain number of > rows from a table. For example I want select the 5 most recent > currency exchange rates for the canadian dollar. If anyone > have any suggestion or need > further information please email me. Thank you very much. > > > Charley > > > Email: cchen@transre.com > -perryd (Guru) ==================================================================== = Perry Dillard - Chief Architect Direct Dial: (206)517-6430 = = FourGen Software, Inc. FAX: (206)522-0054 = = FourGen Building Tech. Support: (800)444-3398 = = 115 NE 100th Street Sales: (800)333-4436 = = Seattle, W.A. 98125-8098 = = = = e-mail: perryd@fourgen.com Web Site http://www.fourgen.com = = = = Home Page: http://www.geocities.com/SiliconValley/3198 = ====================================================================