Groups in C API

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Groups in C API

Stephan Buchert-2
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 group by expression is also one of the result columns, but
this is not always necessarily the case.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: [EXTERNAL] Groups in C API

Hick Gunter
What do you mean with groups ending and starting? The GROUP BY clause has the effect of returning one record per group (i.e. distinct tuple of the group expression), with the accumulated values belonging to that group. Each result record is therefore in a separate group.

SQLite will (except for special cases, where the GROUP BY and ORDER BY clauses can be satisfied by an index on the input rows) need to read ALL of the input rows before it can output even the first result row.

-----Urspr√ľngliche Nachricht-----
Von: sqlite-users [mailto:[hidden email]] Im Auftrag von Stephan Buchert
Gesendet: Montag, 29. Jänner 2018 16:19
An: [hidden email]
Betreff: [EXTERNAL] [sqlite] Groups in C API

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 group by expression is also one of the result columns, but this is not always necessarily the case.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


___________________________________________
 Gunter Hick | Software Engineer | Scientific Games International GmbH | Klitschgasse 2-4, A-1130 Vienna | FN 157284 a, HG Wien, DVR: 0430013 | (O) +43 1 80100 - 0

May be privileged. May be confidential. Please delete if not the addressee.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Groups in C API

Simon Slavin-3
In reply to this post by Stephan Buchert-2


On 29 Jan 2018, at 3:19pm, Stephan Buchert <[hidden email]> 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-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users