[sqlite] how to use group_concat uniquely

2011-01-19 Thread Noah Hart
I am having difficulty trying to return data in a very compact form. Here is a simple example that will explain the problem: I have a table with column E, T and P containing data such as A, 1, R A, 1, S A, 2, R A, 2, S Trying the query select E, group_concat(T,';'), group_concat(P,';') give me

Re: [sqlite] how to use group_concat uniquely

2011-01-19 Thread Nicolas Williams
On Wed, Jan 19, 2011 at 09:19:54AM -0800, Noah Hart wrote: Any ideas? You have two columns to sub-group by independently, as it were. You need correlated sub-queries to get that done: sqlite SELECT f1.e, (SELECT group_concat(f2.t, ';') ... FROM foo f2 WHERE f1.e = f2.e GROUP BY f2.p),

Re: [sqlite] how to use group_concat uniquely

2011-01-19 Thread Igor Tandetnik
On 1/19/2011 12:19 PM, Noah Hart wrote: I am having difficulty trying to return data in a very compact form. Here is a simple example that will explain the problem: I have a table with column E, T and P containing data such as A, 1, R A, 1, S A, 2, R A, 2, S Trying the query select E,

Re: [sqlite] how to use group_concat uniquely

2011-01-19 Thread Noah Hart
On 1/19/2011 12:19 PM, Noah Hart wrote: I am having difficulty trying to return data in a very compact form. Here is a simple example that will explain the problem: I have a table with column E, T and P containing data such as A, 1, R A, 1, S A, 2, R A, 2, S Trying the query select

Re: [sqlite] how to use group_concat uniquely

2011-01-19 Thread Igor Tandetnik
On 1/19/2011 12:51 PM, Noah Hart wrote: select E, replace(group_concat(distinct T), ',', ';'), replace(group_concat(distinct P), ',', ';') from MyTable; Ahhh the DISTINCT keyword was what I'm missing. However, this may be a bug, when I use group_concat(DISTINCT T, ';') I get the error message

Re: [sqlite] how to use group_concat uniquely

2011-01-19 Thread Noah Hart
Igor Tandetnik wrote: On 1/19/2011 12:51 PM, Noah Hart wrote: select E, replace(group_concat(distinct T), ',', ';'), replace(group_concat(distinct P), ',', ';') from MyTable; Ahhh the DISTINCT keyword was what I'm missing. However, this may be a bug, when I use group_concat(DISTINCT T,