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

2022-08-22 Thread Wim Bertels
Perry Smith schreef op ma 15-08-2022 om 08:49 [-0500]: > I like to have what I call “baby sitting” messages such as “Completed > 15 out of 1023”.  To do this, I need the number of results a query > returns but I also need the results. > > Currently I’m doing this with two queries such as: > >    

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

2022-08-17 Thread Peter J. Holzer
On 2022-08-16 14:42:48 -0700, Bryn Llewellyn wrote: > hjp-pg...@hjp.at wrote: > The OP wants some kind of progress indicator. To be useful, such > an indicator should be approximately linear in time. I.e. if your [...] > > > I see, Peter. You’d read the OP’s mind. Not much mind-readi

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

2022-08-16 Thread Bryn Llewellyn
> hjp-pg...@hjp.at wrote: > > That's not quite what I meant. I meant "I don't think there can be what you > want with just one query", > > The OP wants some kind of progress indicator. To be useful, such an indicator > should be approximately linear in time. I.e. if your query returns 1 row

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

2022-08-16 Thread Peter J. Holzer
On 2022-08-15 12:20:44 -0700, Bryn Llewellyn wrote: > > p...@easesoftware.com wrote: > > Currently I’m doing this with two queries such as: > > SELECT COUNT(*) FROM table WHERE …. expression … > SELECT * FROM table WHERE …. expression … >

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

2022-08-16 Thread David Rowley
On Tue, 16 Aug 2022 at 21:15, Walter Dörwald wrote: > select count(*) over (), e.* from email.email e; Depending on the complexity of the query, putting the count(*) as a subquery in the SELECT clause might execute more quickly. i.e. select (select count(*) from email.email) c, * from email.email

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

2022-08-16 Thread Walter Dörwald
On 16 Aug 2022, at 0:13, Rob Sargent wrote: On 8/15/22 14:37, Perry Smith wrote: On Aug 15, 2022, at 08:55, David G. Johnston wrote: On Monday, August 15, 2022, Perry Smith wrote: I’ve been toying with row_number() and then sort by row_number descending and pick off the first

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

2022-08-15 Thread Rob Sargent
On 8/15/22 14:37, Perry Smith wrote: On Aug 15, 2022, at 08:55, David G. Johnston wrote: On Monday, August 15, 2022, Perry Smith 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

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

2022-08-15 Thread Perry Smith
> On Aug 15, 2022, at 08:55, David G. Johnston > wrote: > > On Monday, August 15, 2022, Perry Smith > 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

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

2022-08-15 Thread Bryn Llewellyn
>>> p...@easesoftware.com wrote: >>> >>> Currently I’m doing this with two queries such as: >>> >>> SELECT COUNT(*) FROM table WHERE …. expression … >>> SELECT * FROM table WHERE …. expression … >>> >>> But this requires two queries. Is there a way to do th

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

2022-08-15 Thread Peter J. Holzer
On 2022-08-15 08:49:33 -0500, Perry Smith wrote: > I like to have what I call “baby sitting” messages such as “Completed > 15 out of 1023”. To do this, I need the number of results a query > returns but I also need the results. > > Currently I’m doing this with two queries such as: > > SELEC

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

2022-08-15 Thread David G. Johnston
On Monday, August 15, 2022, Perry Smith 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.

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

2022-08-15 Thread Perry Smith
I like to have what I call “baby sitting” messages such as “Completed 15 out of 1023”. To do this, I need the number of results a query returns but I also need the results. Currently I’m doing this with two queries such as: SELECT COUNT(*) FROM table WHERE …. expression … SELECT * FROM