Re: Can I get the number of results plus the results with a single query?

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Perry Smith <pedz(at)easesoftware(dot)com>
Cc: pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Can I get the number of results plus the results with a single query?
Date: 2022-08-15 13:55:17
Message-ID: CAKFQuwYR-kmTsRJDQ-2US_KR1jvjORceUMsO5jv9duZBrtZqwg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Monday, August 15, 2022, Perry Smith <pedz(at)easesoftware(dot)com> wrote:
>
> I’ve been toying with row_number() and then sort by row_number descending
> and pick off the first row as the total number.
>

Use count as a window function.

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message jian he 2022-08-15 15:52:52 lateral join with union all
Previous Message Perry Smith 2022-08-15 13:49:33 Can I get the number of results plus the results with a single query?