Welcome to WebmasterWorld Guest from 54.166.222.116

Forum Moderators: open

Message Too Old, No Replies

SQL query - getting detailed accounts within a GROUP BY result

getting results that aren't what i want

     
9:36 pm on Dec 20, 2005 (gmt 0)

5+ Year Member



Not getting the data that I want out of my query. What am i doing wrong? Using MySQL and an open-source front end called SQLyog.

here's my SQL :

select Q4 QSTN,
Q2 UNT,
QMP_1 MLPLN,
Q4, COUNT(1) CNT

from DSsurvey

GROUP BY QSTN

---------------------------------------
My results :

"QSTN""UNT""MLPLN""Q4""CNT"
\N\N\N\N"24"
"0""1""2""0""5"
"1""2""1""1""155"
"2""1""3""2""329"
"3""2""1""3""198"
"4""1""1""4""47"
"5""1""1""5""12" [/pre]

----------------------------------------

What I want is, within all the QSTN=5 results, a listing and count of all the possible combinations.

For example:

QSTN UNT MPLN CNT
5 1 2 3
5 2 1 4
5 1 1 2 ...etc

you see? so that for every QSTN=5, you see all the different factors and can count them up. Rather than the results I get above, where 1 line of data output is QSTN=5 with a total count of 12.

Thanks, B

9:47 pm on Dec 20, 2005 (gmt 0)

5+ Year Member



trying to line up the columns with pre and code tags. sorry i couldn't.
12:26 pm on Dec 22, 2005 (gmt 0)

10+ Year Member



Sorry, with those weird abbreviations and the code not lining up, I don't get what you're asking...
2:40 pm on Dec 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Expand your GROUP BY clause to include the extra fields - that should allow you to get the multi-question summary you're looking for.

- Tony

 

Featured Threads

Hot Threads This Week

Hot Threads This Month