sqlite3
I have two tables. One contains some lists and the other contains each list's items.
I want to create a select statement that grabs the rows in the lists table, but also creates a column which is a comma-delimited summary of the items in each list.
I have this working as follows:
select
master._id as _id,
master.name as name,
master.created_on as created_on,
group_concat(items.name, ', ')
from
tablea master
join
tableb items
on
master._id = items.master_id
group by
master._id
However, I would like to name the column returned by the group_concat as "summary" like so:
select
master._id as _id,
master.name as name,
master.created_on as created_on,
group_concat(items.name, ', ') as summary
from
tablea master
join
tableb items
on
master._id = items.master_id
group by
master._id
When I do this, I get an sql error: "SQL error: near "summary": syntax error
How can I achieve what I'm wanting to do?
I would also like to order the items in the group_concat alphabetically descending, but naming the column is my first priority.