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 " ;
asked Sep 19, 2014 at 18:59
user47795user47795
1 Answer 1
What about something like:
select
height || 'x' || width as dimensions,
count(*) as number_of_banners
from
rv_banners
group by
height, width ;
ypercubeTM
99.7k13 gold badges217 silver badges306 bronze badges
answered Sep 19, 2014 at 19:11
lang-sql