I'm sorry if this fells like code golf, but I trying to avoid getting data out of the database, do processing in application code for something that would require slooow loops over a data set where there are indices that would help in the grouping.
Is there any way at all to get from a data set like this:
sqlite> create table tst (id INTEGER, label TEXT, variable TEXT, value FLOAT);
sqlite> insert into tst values (1,"label1","variable 1",1.2);
sqlite> insert into tst values (1,"label2","variable 2",2.2);
sqlite> insert into tst values (1,"label3","variable 3",3.2);
sqlite> select * from tst;
id label variable value
---------- ---------- ---------- ----------
1 label1 variable 1 1.2
1 label2 variable 2 2.2
1 label3 variable 3 3.2
to be returned like this:
sqlite> <magic query here>
id label1_variable1 label2_variable2 label3_variable3
---------- ---------- ---------- ----------
1 1.2 2.2 3.2
that is, in wide format rather than long format?
Please advice, or help me just by proving that is cannot be done.
Aucun commentaire:
Enregistrer un commentaire