Thanks, Igor. Yes, are moving our sparse matrix to different tables:
Id | RelationalIdentifier | ColA 1 a X 2 b A Id | RelationalIdentifier | ColB 1 a Y 2 b B Id | RelationalIdentifier | ColC 1 a Z 2 b C How can I adapt your query to this new table schema? On Thu, Dec 5, 2013 at 10:33 AM, Igor Tandetnik <i...@tandetnik.org> wrote: > On 12/5/2013 1:15 PM, Hayden Livingston wrote: > >> I have a table schema such like >> >> ID | Col1 | Col2 | Col3 | Value >> 1 a null null X >> 2 null a null Y >> 3 null null a Z >> 4 b null null A >> 5 null b null B >> 6 null null b C >> >> Right now these are in the same table (they may be different tables in the >> near future, but I don't think that impacts this discussion) >> >> I want to "PIVOT" this data such that: >> >> A | Value | Value | Value >> a X Y Z >> b A B C >> > > select coalesce(Col1, Col2, Col3) as A, > max(case when Col1 is null then null else Value end) as Value1, > max(case when Col2 is null then null else Value end) as Value2, > max(case when Col3 is null then null else Value end) as Value3 > from MyTable group by A; > > I must say you chose a very inconvenient table schema. What's with the > sparse matrix? What kind of queries is this good for? > -- > Igor Tandetnik > > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users