COUNT Function (Full Version)

All Forums >> [Web Development] >> ASP, PHP, and Database



Message


hzarabet -> COUNT Function (6/2/2009 22:53:12)

Hi Spooky and Co! It has been a long time since I have been here. I hope all have been well and at least somewhat prosperous the last couple of years!!!

I set up a survey. For each of 12 questions there are 3 possible answers. Additonally, there are 3 subsets of users I want to further analyze these results with. I hope I am wrong, but the only want I know of obtaining the count for each option is to the use the COUNT function. If this is the case I will need to have 12x3x3 (108) COUNT SQL calls on my page!!!!! This will be a private page that is just used by me.

For example, just for Question 1 I would need to following to tally all my results!!!

SQL COUNT(*) FROM MyTable WHERE Question1 = 'Y' And USER = 'P'
SQL COUNT(*) FROM MyTable WHERE Question1 = 'N' And USER = 'P'
SQL COUNT(*) FROM MyTable WHERE Question1 = 'S' And USER = 'P'
SQL COUNT(*) FROM MyTable WHERE Question1 = 'Y' And USER = 'C'
SQL COUNT(*) FROM MyTable WHERE Question1 = 'N' And USER = 'C'
SQL COUNT(*) FROM MyTable WHERE Question1 = 'S' And USER = 'C
SQL COUNT(*) FROM MyTable WHERE Question1 = 'Y' And USER = 'L'
SQL COUNT(*) FROM MyTable WHERE Question1 = 'N' And USER = 'L'
SQL COUNT(*) FROM MyTable WHERE Question1 = 'S' And USER = 'L'


Is there a more efficient way to do this????

Thank you!!




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.0625