select count(*) and limit

From: Verena Ruff <lists(at)triosolutions(dot)at>
To: pgsql-novice(at)postgresql(dot)org
Subject: select count(*) and limit
Date: 2006-05-18 10:51:10
Message-ID: 446C519E.6050507@triosolutions.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi,

sometimes I have queries with a LIMIT statement. Now I'd like to present
the user the returned records and inform him how many records there are
if there was no LIMIT statement. Is it possible to get all neccessary
information with one query?
This works:
SELECT * FROM table LIMIT 20
SELECT count(*) FROM table
But is it possible to have one query returning both, the records and the
count?

regards,
Verena

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Sean Davis 2006-05-18 11:10:03 Re: select count(*) and limit
Previous Message A. Kretschmer 2006-05-18 05:56:47 Re: Querying from two tables as if they were appended