|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Crosstab in MS SQL
I am trying to create a report for looking at the results of a survey. The table has the following layout:
UID int, Answer char -- values of a,b,c,d,e uid answer 1 a 2 b 3 d 4 e the uid is tied to another table UID int, State uid state 1 CA 2 CA 3 VA 4 MI What i want to do is to find out by state, the number of answers to each question. I would like the report to look like this: state A B C D E CA 1 1 0 0 0 MI 0 0 0 0 0 VA 0 0 0 1 0 Is there a way to do this in the query or do I have to just get the recordset and use asp to manipulate the data????? Thanks |
|
#2
|
||||
|
||||
|
Take this article as an example, it's exactly what you need http://www.devshed.com/Server_Side/...LWiz/page1.html
__________________
My blog about OpenSource Databases PDF tutorials about OSS databases, DBMonster ... Please contribute to Open Source Development, fill bug reports!!! Developer Shed eSupport Commented my.ini/my.cnf (PLEASE ADD YOUR OWN CONFIG TRICK) Understanding SQL Joins An introduction to database normalization Natural or Surrogate key Custom ordering for your results Correlated and uncorrelated subqueries |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > Crosstab in MS SQL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|