Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 6AD7B634875 for ; Thu, 3 Sep 2009 22:02:40 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 97924-08 for ; Fri, 4 Sep 2009 01:02:32 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from polaris.pinpointresearch.com (66-7-238-130.static-ip.telepacific.net [66.7.238.130]) by mail.postgresql.org (Postfix) with ESMTP id DBA75633860 for ; Thu, 3 Sep 2009 22:02:32 -0300 (ADT) Received: from [192.168.1.179] (betelgeuse.pinpointresearch.com [192.168.1.179]) by polaris.pinpointresearch.com (Postfix) with ESMTP id EA0A6E00EC82; Thu, 3 Sep 2009 18:02:30 -0700 (PDT) Message-ID: <4AA06726.6070107@pinpointresearch.com> Date: Thu, 03 Sep 2009 18:02:30 -0700 From: Steve Crawford User-Agent: Thunderbird 2.0.0.21 (X11/20090318) MIME-Version: 1.0 To: bilal ghayyad CC: pgsql-sql@postgresql.org Subject: Re: LIMIT 1; The Integer part only References: <26617.92501.qm@web53910.mail.re2.yahoo.com> In-Reply-To: <26617.92501.qm@web53910.mail.re2.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200909/22 X-Sequence-Number: 33087 bilal ghayyad wrote: > 1) When writing the function (I mean sql function) in the postgresql, I noticed the use for LIMIT 1, but did not understand what does it mean and why we use it? > Limit return to 1 record (or other specified number). Note that without ORDER BY, there is no guarantee of which record will show up at the top of the list. See also OFFSET. I.e. to skip the first 30 records and only return the next 10 (records 31-40) in your list: SELECT * from foo order by bar LIMIT 10 OFFSET 30; > 2) Also in the function (the sql function) in the postgresql, if I need to take the integer part of the number, which math function can do this for me? > > For example, I have 3.900 and I need only the 3 (the integer part), which math function to be used? > floor(3.900) Cheers, Steve