Hi,
I'm suffering from some db ignorance. I was trying to do the following in another database and found that I couldn't and wanted to know if Postgres is able. Essentially I'm trying to rotate a table for the purpose of my view. Here's an example.
First, I have a table like this:
I am trying to create a sql statement that returns this data rearranged into a view or temp table that utilizes the Class for its headers so it looks like this:
There could be many different 'Class'es and I want the columns returned to be dynamic according to however many Classes are set and using the Field_ID for the primary key of the newly created view/table. Hope that makes sense. Is Postgres the way to go?
Thanks!
I'm suffering from some db ignorance. I was trying to do the following in another database and found that I couldn't and wanted to know if Postgres is able. Essentially I'm trying to rotate a table for the purpose of my view. Here's an example.
First, I have a table like this:
Code:
_________ ________ _____ _____
[prime_key] [Field_ID] [Field] [Class]
--------- -------- ----- -----
1 1A 'foo' 'A'
2 2A 'bar' 'A'
3 1A 'tst' 'B'
4 3A 'hi.' 'B'
I am trying to create a sql statement that returns this data rearranged into a view or temp table that utilizes the Class for its headers so it looks like this:
Code:
________ _ _
[Field_ID] [A] [B]
-------- ----- -----
1A 'foo' 'tst'
2A 'bar' null
3A null 'hi.'
There could be many different 'Class'es and I want the columns returned to be dynamic according to however many Classes are set and using the Field_ID for the primary key of the newly created view/table. Hope that makes sense. Is Postgres the way to go?
Thanks!