Eugene R. Miller wrote:
This is kind of a silly question is there an easy way to ...

SELECT Status, rating, COUNT(*) FROM song GROUP BY pldupldqd, rating ORDER BY Status, rating DESC

This gives me all the information I need ...

What I would like to do is something... like

SELECT rating, count(WHERE pldupldqd = 0), count (WHERE pldupldqd = 1), COUNT (WHERE pldupldqd = 2) FROM song GROUP BY rating


The idea is to get...


3 different columns counting what it equals.


Yes, it's possible, the solution is very easy:

SELECT rating,
  sum(CASE pldupldqd WHEN 0 THEN 1 ELSE 0 END),
  sum(CASE pldupldqd WHEN 1 THEN 1 ELSE 0 END),
  sum(CASE pldupldqd WHEN 2 THEN 1 ELSE 0 END),
  ....


Alternatively, you case use function IF(), instead of CASE.



Erm
-------------------------------
www.the-erm.com




--
For technical support contracts, visit https://order.mysql.com/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Mr. Alexander Barkov <[EMAIL PROTECTED]>
 / /|_/ / // /\ \/ /_/ / /__   MySQL AB, Full-Time Developer
/_/  /_/\_, /___/\___\_\___/   Izhevsk, Russia
       <___/   www.mysql.com   +7-912-856-80-21


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to