Re: [sqlite] Ordering a GROUP BY, or other concatenating tricks?

2017-10-04 Thread petern
You could also write it even more clearly as: WITH IndexedLines AS (SELECT LineText FROM DocLines WHERE DocID = 10 ORDER BY LineIndex) SELECT group_concat(LineText, char(10)) FROM IndexedLines; That code will actually work. As it is not C, SQLite will not recognize the '\n' C escaped line feed

Re: [sqlite] Ordering a GROUP BY, or other concatenating tricks?

2017-10-04 Thread Richard Hipp
On 10/4/17, sub sk79 wrote: > On Wed, Oct 4, 2017 at 12:29 PM, Richard Hipp wrote: > >> >> This restriction on the query flattener causes your example >> query above to do what you want. >> > > If subquery-flattening needs to be disabled explicitly, is using

Re: [sqlite] Ordering a GROUP BY, or other concatenating tricks?

2017-10-04 Thread sub sk79
On Wed, Oct 4, 2017 at 12:29 PM, Richard Hipp wrote: > > This restriction on the query flattener causes your example > query above to do what you want. > If subquery-flattening needs to be disabled explicitly, is using "LIMIT -1 OFFSET 0 " the recommended way? > SQLite

Re: [sqlite] Ordering a GROUP BY, or other concatenating tricks?

2017-10-04 Thread Richard Hipp
On 10/4/17, Doug Nebeker wrote: > Is it just a matter of using sqlite3_create_function to register a function > that guarantees it will concatenate in the order rows are received? Would > that guarantee that your example works, or is order no longer guaranteed > once they

Re: [sqlite] Ordering a GROUP BY, or other concatenating tricks?

2017-10-04 Thread Simon Slavin
On 4 Oct 2017, at 4:06pm, Doug Nebeker wrote: > Is it just a matter of using sqlite3_create_function to register a function > that guarantees it will concatenate in the order rows are received? Would > that guarantee that your example works, or is order no longer

Re: [sqlite] Ordering a GROUP BY, or other concatenating tricks?

2017-10-04 Thread Doug Nebeker
Is it just a matter of using sqlite3_create_function to register a function that guarantees it will concatenate in the order rows are received? Would that guarantee that your example works, or is order no longer guaranteed once they leave the inner select? SELECT group_concat(LineText, '\n')

Re: [sqlite] Ordering a GROUP BY, or other concatenating tricks?

2017-10-04 Thread Jean-Luc Hainaut
On 04/10/2017 02:16, Simon Slavin wrote: The differences between SQLite and (a.o.) MySQL versions of "group_concat" are a recurrent topic. Since I often need to specify "distinct", "order by", "order direction" and "separator", I have written a simple UDF class that simulates the MySQL full

Re: [sqlite] Ordering a GROUP BY, or other concatenating tricks?

2017-10-03 Thread Simon Slavin
On 3 Oct 2017, at 11:13pm, Doug Nebeker wrote: > How can I select a document and get the complete sorted text back in a single > row (so I can do a JOIN on a different table with additional information)? There is a way which will probably work but the documentation