Please consider this example:
---begin---
#!/bin/sh
DB=sq.sqlite
rm -f $DB
sql() {
echo "$1" | sqlite3 $DB
}
sql "create table a(id integer not null, primary key(id));"
sql "create table b(oid integer not null, chr char null);"
sql "insert into a values(1);"
sql "insert into a values(2);"
sql "insert into b values(1,'y');"
sql "insert into b values(1,'x');"
sql "insert into b values(2,'x');"
sql "insert into b values(2,'y');"
sql "select
a.id,
(select group_concat(chr)
from b
where oid = a.id
group by oid
order by chr
)
from
a;"
---end---
It returns this dataset:
1|y,x
2|x,y
The 'order by' clause doesn't work, because if it did the result would
have been:
1|x,y
2|x,y
sqlite3-3.9.2
Yuri