Ok I have a database that includes two tables. A datatable that looks like:
and a metadata table that looks like:
I want to select columns from the datatable based on the variable column in the metadata table. Such that I end up with:
Thus I need to do something like:
SELECT [pivot variable.metadata] FROM datatable;
Anyone know how to do the pivot of the metadata.variable column in SQLite?
Code:
a b c d e f g h i
1 -2.1772586 0.54904839 -0.09064777 -0.30904735 0.902645747 0.25056056 -0.07167768 0.5477423 -0.06540162
2 0.8191437 -0.29184975 0.55046901 -0.14786375 -1.365494264 -0.04492767 0.53076043 0.6104837 -0.42441851
3 0.8557512 -0.08171739 0.14697551 -0.86271463 1.075134669 -1.95978783 -0.63262255 0.8531504 -0.58840064
4 0.3146546 -1.83335248 -0.94553173 0.29263775 -1.291303249 0.85612084 -1.38643377 -0.5012100 1.88951237
5 -0.4509690 -0.95023522 0.98457069 0.01282259 -0.002325744 0.48373935 -1.16434104 0.8342430 -0.40744770
6 -1.1979267 -0.01669569 -1.18147487 0.71695038 -0.320249844 -0.38894801 -0.08486285 -0.2450969 1.18439034
7 -0.4765806 0.15399498 0.22767422 0.29262747 -0.732538913 -2.43904768 1.20040915 -1.9010115 0.21889756
8 -1.7473071 0.98079991 -0.23776151 1.26167730 -0.643288192 1.36559614 -1.24053485 -1.0701088 0.30020588
9 -1.3483016 -0.91244697 -0.83976553 1.25269789 -0.709669386 2.08028882 0.38032189 1.9496645 0.38533128
10 -1.0991387 -0.61460572 0.75277683 0.91604754 0.847483549 0.12921561 0.56796830 0.3605553 0.69194487
Code:
variable descritpion
1 a some description
2 b some description
3 c some description
Code:
a b c
1 -2.1772586 0.54904839 -0.09064777
2 0.8191437 -0.29184975 0.55046901
3 0.8557512 -0.08171739 0.14697551
4 0.3146546 -1.83335248 -0.94553173
5 -0.4509690 -0.95023522 0.98457069
6 -1.1979267 -0.01669569 -1.18147487
7 -0.4765806 0.15399498 0.22767422
8 -1.7473071 0.98079991 -0.23776151
9 -1.3483016 -0.91244697 -0.83976553
10 -1.0991387 -0.61460572 0.75277683
SELECT [pivot variable.metadata] FROM datatable;
Anyone know how to do the pivot of the metadata.variable column in SQLite?