homepage Welcome to WebmasterWorld Guest from 54.237.134.62
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe and Support WebmasterWorld
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderators: physics

Databases Forum

    
SQL query - getting detailed accounts within a GROUP BY result
getting results that aren't what i want
bowie101




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

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

 

bowie101




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

trying to line up the columns with pre and code tags. sorry i couldn't.

bigtoga




msg:1580373
 12:26 pm on Dec 22, 2005 (gmt 0)

Sorry, with those weird abbreviations and the code not lining up, I don't get what you're asking...

Dreamquick




msg:1580374
 2:40 pm on Dec 22, 2005 (gmt 0)

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved