Re: [sqlite] Groups in C API

2018-01-30 Thread Kees Nuyt
On Tue, 30 Jan 2018 12:16:32 +0100, Stephan Buchert wrote: > Thanks for the replies. > > Allowing non-aggregate columns in aggregate queries is very useful, as > shown with the min/max functions. It is forbidden in most SQL dialects, only supported by SQLite as a dirty

[sqlite] Groups in C API

2018-01-30 Thread Stephan Buchert
Thanks for the replies. Allowing non-aggregate columns in aggregate queries is very useful, as shown with the min/max functions. Probably with this feature comes that SQLite even allows all non-aggregate columns in SELECTs with GROUP BY. Perhaps the documentation should warn more clearly, that

Re: [sqlite] Groups in C API

2018-01-29 Thread Cezary H. Noweta
Hello, On 2018-01-29 18:08, Stephan Buchert wrote: But then I have a related question: to get my hands on each row in SELECTs with GROUP BY I could write an aggregate extension function. How do I see there, when a group ends and a new one starts? I.e. How do I implement the xStep and xFinal C

[sqlite] Groups in C API

2018-01-29 Thread Stephan Buchert
Ok, I should have tested this before asking. I had assumed that "If the SELECT statement is *a non-aggregate query*, then each expression in the result expression list is evaluated for each row in the dataset filtered by the WHERE clause" on https://www.sqlite.org/lang_select.html#resultset

Re: [sqlite] Groups in C API

2018-01-29 Thread Simon Slavin
On 29 Jan 2018, at 3:19pm, Stephan Buchert wrote: > is there a way to know when a group ends and the next starts? No. Not even SQLite knows this. Sorry. You have to monitor the group column in your own software. Simon.

[sqlite] Groups in C API

2018-01-29 Thread Stephan Buchert
When processing SELECT ... statements having a GROUP BY clause, i.e. SELECT ... GROUP BY ...; in C, i.e. with a loop like rc=sqlite3_step(stmt); while rc==SQLITE_ROW { ... rc=sqlite3_step(stmt); } is there a way to know when a group ends and the next starts? I have this of course if the