I've got a big query where I SELECT SUM(column) which is grouped by another column... I also want to select the number of rows that equal a certain value. I don't want to exclude those not matching from the sum function (so its not just a WHERE clause) I just want to COUNT if they are equal to a particular value (rather like COUNTIF in excel). Is there a built in SQL function for this? Otherwise I'll have to do a separate query for each one and do mysql_num_rows, which would take extra time.