Quantcast
Channel: Questions in topic: "union-all"
Viewing all articles
Browse latest Browse all 18

Use a pivot in a UNION

$
0
0
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. SELECT a1.id, a1.city, a1.Year, a1.totalusages FROM table1 a1 UNION ALL SELECT a2.id, a2.city, a2.Year, a2.totalsites FROM table2 a2

Viewing all articles
Browse latest Browse all 18

Trending Articles