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

From: Perry Smith <pedz(at)easesoftware(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: ***SPAM*** Re: Can I get the number of results plus the results with a single query?
Date: 2022-08-15 20:37:12
Message-ID: 8D4B16FB-BE56-446E-BDE5-D12C69B2C3DB@easesoftware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> On Aug 15, 2022, at 08:55, David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
>
> On Monday, August 15, 2022, Perry Smith <pedz(at)easesoftware(dot)com <mailto: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.

I see others are commenting after David’s update so:

Thank you David.

This seems to work for me:

SELECT count(*) OVER (), id, basename, sha1 FROM dateien WHERE (lower(ext) in ( 'pxd' ) and ftype = 'file') ORDER BY sha1;

This has, e.g. 73, in the first column for all of the rows.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rob Sargent 2022-08-15 22:13:49 Re: ***SPAM*** Re: Can I get the number of results plus the results with a single query?
Previous Message Bryn Llewellyn 2022-08-15 19:20:44 Re: Can I get the number of results plus the results with a single query?