Re: [sqlite] Is it possible to transpose a table using SQL?

2019-04-01 Thread Jake Thaw
Hi Shane, You might be interested in trying out my pivot virtual table implementation. https://github.com/jakethaw/pivot_vtab This will cater for changing values, but like a VIEW implementation, it does not satisfy your criteria of dynamically changing rows/columns. Changes to rows/columns can

Re: [sqlite] Is it possible to transpose a table using SQL?

2019-04-01 Thread Simon Slavin
On 1 Apr 2019, at 10:18am, Dominique Devienne wrote: > I can't seem to find that one, but I found another here: > https://metacpan.org/pod/SQLite::VirtualTable::Pivot I looked at that one, but it doesn't do what OP wants, which is to swap rows and columns without the programmer having to

Re: [sqlite] Is it possible to transpose a table using SQL?

2019-04-01 Thread Dominique Devienne
On Mon, Apr 1, 2019 at 7:15 AM Shane Dev wrote: > [...]. By "dynamically changing table", I meant the number of columns and > rows could could change > after the dependant view was created. it appears this is impossible using > only SQL > It's possible using a virtual table, which years ago a

Re: [sqlite] Is it possible to transpose a table using SQL?

2019-03-31 Thread Shane Dev
Hi Keith, Jean-Luc I should have mentioned my shell is configured to display column headers Product/Region|Belgium|France|USA for table t1 and Product/Region|Oil_filter|Spark_plug|Coolent for view v1. By "dynamically changing table", I meant the number of columns and rows could could change after

Re: [sqlite] Is it possible to transpose a table using SQL?

2019-03-31 Thread Keith Medcalf
On Sunday, 31 March, 2019 14:07, Shane Dev 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;

Re: [sqlite] Is it possible to transpose a table using SQL?

2019-03-31 Thread Jean-Luc Hainaut
If by "a dynamically changing table " you mean that any data change (not schema change) in t1 will propagate to v1, and if the set of Product values doesn't change, then you can try this: create table t1(Product,Belgium,France,USA); insert into t1 values

Re: [sqlite] Is it possible to transpose a table using SQL?

2019-03-31 Thread Simon Slavin
On 31 Mar 2019, at 9:07pm, Shane Dev wrote: > Is it possible to create a view which switches rows and columns of a > dynamically changing table? Sorry, but no. A VIEW is just a saved SELECT statement. If you can't do it in a SELECT statement, you can't do it in a view. And you can't do

[sqlite] Is it possible to transpose a table using SQL?

2019-03-31 Thread Shane Dev
Hello, 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