I am trying to combine ALL the records from BOTH OF these tables. Each TABLE has SOME id's that the other does not have so I don't want to lose any in the process. My problem is the TotalUsages and TotalSites data is all falling under the TotalUsages column. I need to pivot the TotalSites column so it becomes it's own column.
asked Feb 21, 2012 at 06:54 PM in Default
If you want TotalSites as it's own column
FROM table2 a2
answered Feb 21, 2012 at 06:56 PM
Kev Riley ♦♦
I'm interpreting your question differently to the way @Kev Riley has done...
What I suggest is builds on what you've done.
Firstly, some temporary tables and data:
OK, so what we're doing is adding another column to indicate whether the source row is coming from the Usages or Sites table, and using that to
The results here:
If you want "0" rather than "NULL", replace the first line of the SELECT with:
answered Feb 21, 2012 at 09:46 PM