I’m working on trying to generate a report from a couple of database tables. The simplified version looks like this
Campaign ---------- CampaignID Source ----------------------- Source_ID | Campaign_ID Content --------------------------------------------------------- Content_ID | Campaign_ID | Content_Row_ID | Content_Value
The report needs to read like this:
CampaignID - SourceID - ContentRowID(Value(A)) - ContentRowID(Value(B))
Where ContentRowID(Value(A)) means ‘Find a row the has a given CampaignID, and a ContentRowId of ‘A’ and then get the ContentValue for that row’
Essentially, I have to ‘pivot’ (I think that’s the correct term) the rows into columns…
It’s an Oracle 10g database…
Any suggestions?
This is my first stab at it. Refinement coming once I know more about the contents of the Content table.
First, you need a temporary table:
Now we’re ready to query.