[thelist] Getting Specific Numbers from mySQL Database Using PHP

r937 rudy at r937.com
Sat Sep 6 06:19:20 CDT 2008


> For example, if users from company A (amongst other companies)
> takes tests 1, 2 and 3 and I want to find out their results for 
> all three tests and list those results, how do I do this?

SELECT test
     , SUM(CASE WHEN answer='correct'
                THEN 1 ELSE 0 END)  AS correct_results
  FROM tests
 WHERE company = 'A'
GROUP
    BY test

rudy
http://r937.com/




More information about the thelist mailing list