I am trying to write a SQL Server 2008 query which will output data into subtotaled columns. My SQL skills are pretty poor still, so I could really use some help.
I have two tables, A and B.
A.user (unique)
A.answer <- can only be one of two answers, 'Answer1' or 'Answer2'
B.user (unique)
B.zip
What I am trying to do is write a SQL statement that generates a four column output that summarizes answer by zip. Like this:
Zip Answer1 Answer2 Total
----------------------------------
12345 25 22 47
23456 7 0 7
45678 0 15 15
Any sage advice?
Thanks!
-tony
I think that this is what you need:
Here’s a fiddle: http://sqlfiddle.com/#!3/60916/2/0