How can I create a table from an existing table in SQL but using cells from the old table as columns in the new table?
I have a table,
and I want to create a new table such as the one below (from the table above)
In SQL, I tried using the following commands. I am able to generate a table with only one column like this,
CREATE TABLE table2 AS
SELECT balance
FROM table1 WHERE balance='currency'
But if I try to do multiple WHERE clause's it doesn't seem to work.
I tried to do,
CREATE TABLE table2 AS
SELECT balance, category
FROM table1 WHERE balance='currency', category= 'date_valid_from'
I also tried using an AND statement but still no luck,
CREATE TABLE table1 AS
SELECT balance, category
FROM table2 WHERE balance='currency' AND category = 'date_valid_from'
This just returns empty columns of 'balance' and 'category' and not the specified Where clauses.
ALSO, the columns in the new tables, are the ones which I selected from the old table. i.e 'balance' and 'category' However I wan't the cells within those columns i.e 'currency' in 'balance' to be the new columns.
Category Data Science