pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
LIMIT 1; The Integer part only
3+ messages / 3 participants
[nested] [flat]

* LIMIT 1; The Integer part only
@ 2009-09-04 00:49 bilal ghayyad <bilmar_gh@yahoo.com>
  2009-09-04 01:02 ` Re: LIMIT 1; The Integer part only Steve Crawford <scrawford@pinpointresearch.com>
  2009-09-04 01:28 ` Re: LIMIT 1; The Integer part only Christophe Pettus <xof@thebuild.com>
  0 siblings, 2 replies; 3+ messages in thread

From: bilal ghayyad @ 2009-09-04 00:49 UTC (permalink / raw)
  To: pgsql-sql

Hello List;

I have two questions:

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?

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?

Any advise?
Regards
Bilal


      



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: LIMIT 1; The Integer part only
  2009-09-04 00:49 LIMIT 1; The Integer part only bilal ghayyad <bilmar_gh@yahoo.com>
@ 2009-09-04 01:02 ` Steve Crawford <scrawford@pinpointresearch.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Steve Crawford @ 2009-09-04 01:02 UTC (permalink / raw)
  To: bilal ghayyad <bilmar_gh@yahoo.com>; +Cc: pgsql-sql

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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: LIMIT 1; The Integer part only
  2009-09-04 00:49 LIMIT 1; The Integer part only bilal ghayyad <bilmar_gh@yahoo.com>
@ 2009-09-04 01:28 ` Christophe Pettus <xof@thebuild.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Christophe Pettus @ 2009-09-04 01:28 UTC (permalink / raw)
  To: bilal ghayyad <bilmar_gh@yahoo.com>; +Cc: pgsql-sql


On Sep 3, 2009, at 5:49 PM, 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?

It restricts the number of rows returned by the SELECT.  You can find  
the documentation here:

	http://www.postgresql.org/docs/8.4/interactive/sql-select.html#SQL-LIMIT

>
> 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?

floor or trunc, depending on the behavior you want for negative numbers:

	http://www.postgresql.org/docs/8.4/interactive/functions-math.html

--
-- Christophe Pettus
    xof@thebuild.com




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2009-09-04 01:28 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-09-04 00:49 LIMIT 1; The Integer part only bilal ghayyad <bilmar_gh@yahoo.com>
2009-09-04 01:02 ` Steve Crawford <scrawford@pinpointresearch.com>
2009-09-04 01:28 ` Christophe Pettus <xof@thebuild.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox