开发者

Query in SQL to show average price for cars of same brand

开发者 https://www.devze.com 2023-03-05 08:31 出处:网络
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.

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
0

精彩评论

暂无评论...
验证码 换一张
取 消