Query in SQL to show average price for cars of same brand
How do I type in query in 开发者_JS百科table "cars" to give me 2 brands I want(there are many cars with same brand) and average prices of all the cars of that brand. http://i.stack.imgur.com/k7fmn.jpg
SELECT brand, avg(price)
FROM cars
WHERE brand IN ('SAAB', 'Volvo')
GROUP BY brand
Without more info, something like this should work:
select brand, avg(price)
from cars
where brand in ('brand1', 'brand2')
group by brand
精彩评论