I have a db where the cells are height and width. (It's for banner ads) Some banners are the same width, but different height, or visa versa. for example: row1 hieght = 600 width = 120 row2 hieght = 600 width = 120 row3 hightt = 600 width = 90 row4 height = 125 width = 125 etc

I want to know how many rows are 600x120, how many are 600x90, etc

How do I fix the sql query as follows to get the info I want?

$sql="SELECT  COUNT(`height`) GROUPED BY (`width` ) 
FROM  `rv_banners` 
WHERE 1 " ;

1 Answer 1


What about something like:

  height || 'x' || width as dimensions,
  count(*) as number_of_banners
group by
  height, width ;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.