On Sunday, 31 March, 2019 14:07, Shane Dev <devshan...@gmail.com> wrote:

>Is it possible to create a view which switches rows and columns of a
>dynamically changing table?

>For example, imagine we have table t1 where both columns and rows
>could change after the view has been created

>sqlite> select * from t1;
>Product/Region|Belgium|France|USA
>Oil_filter|1|2|3
>Spark_plug|4|5|6
>Coolent|7|8|9

>Could view v1 be created such that

>sqlite> select * from v1;
>Product/Region|Oil_filter|Spark_plug|Coolent
>Belgium|1|4|7
>France|2|5|8
>USA|3|6|9

You example is ambiguous.

For example, is the table T1 thus:

create table T1("Product/Region" text not null, Belgium integer not null, 
France integer not null, USA integer not null);
insert into T1 values ('Oil_filter', 1, 2, 3);
insert into T1 values ('Spark_plug', 4, 5, 6);
insert into T2 values ('Coolent', 7, 8, 9);

or so:

create table T1(c0, c1, c2, c3);
insert into T1 values ('Product/Region', 'Belgium', 'France', 'USA');
insert into T1 values ('Oil_filter', 1, 2, 3);
insert into T1 values ('Spark_plug', 4, 5, 6);
insert into T2 values ('Coolent', 7, 8, 9);

If "so", how do you know which column/row is the proposed row/column names?  Or 
do you just want to transpose the matrix?

Please explain what you mean by "dynamically changing table" ... what exactly 
is dynamically changing?  The number of columns?  The number of rows?

Note this is probably relatively simple for kiddie sized data but would be far 
more efficient if you did it at the application level.  It would be even 
simpler if the data were properly normalized.

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.




_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to