Re: Equivalent query
Posted in 2006
luissol wrote: > I have a question is there an equivalent of the "TOP" function of sql > server in informix > > I need something like this but in the informix sintax: > > DECLARE @var1 integer > SET @var1 = (select count(*) from table) > DECLARE @var2 integer > SET @var2 = 200 > select top (@var1 - @var2) * from table > > I'm using C# to develop my application that has access to informix but Question for you? Are you aware that there is no particular order inherent in the way the data is returned from the database? Or, put another way, do you realize that even if we can agree that "SELECT TOP 30 * FROM SomeTable" can be achieved, then the contents you get is indeterminate. If the table isn't fragmented and hasn't had any records deleted, then you will probably get the data in the order it was inserted - but that is far from guaranteed. If you dive into the theory behind databases, you'll find that tables are sets of rows, and sets do not have any order. -- Jonathan Leffler #include <disclaimer.h> Email: jleffler@earthlink.net, jleffler@us.ibm.com Guardian of DBD::Informix v2005.02 -- http://dbi.perl.org/