So I have database with columns "brands" "price" "other stuff"
brands is like volvo, opel and so on. Prices are numbers.
There are several rows with same brand but different prices.
What query do I send to return 1 column with brand names(distinct)
And other column with average price per every brand?
4 replies to this topic
#1
Posted 07 May 2011 - 08:09 AM
|
|
|
#2
Posted 07 May 2011 - 11:41 AM
it depends a little on the database type, but something like
select avg(price), brands from table group by grands
#3
Posted 08 June 2011 - 11:56 PM
Queries are essentially powerful Filters. Queries allow you to decide what fields or expressions are to be shown and what information to be sought.
Queries can select records that fit certain criteria. If you had a list of people and had a gender field you could use a query to select just the males or females in the database.
Queries can select records that fit certain criteria. If you had a list of people and had a gender field you could use a query to select just the males or females in the database.
#4
Posted 19 June 2011 - 03:24 AM
In this problem you made you should know about the key word "GROUP BY".That mean category column data in to distinct filed. finally use AVG key word to find average. Like wise you can write any query using GROUP BY key word.
SELECT brands,AVG(price) from <your_table_name> GROUP BY brands
For more details you can follow this URL.
<http://www.techyv.com/questions/how-group-data-month-when-using-datetime-column-mysql>
SELECT brands,AVG(price) from <your_table_name> GROUP BY brands
For more details you can follow this URL.
<http://www.techyv.com/questions/how-group-data-month-when-using-datetime-column-mysql>
#5
Posted 19 June 2011 - 03:53 AM
In this problem you made you should know about the key word "GROUP BY".That mean category column data in to distinct filed. finally use AVG key word to find average. Like wise you can write any query using GROUP BY key word.
SELECT brands,AVG(price) from <your_table_name> GROUP BY brands
For more details you can follow this URL.
<http://www.techyv.com/questions/how-group-data-month-when-using-datetime-column-mysql>
SELECT brands,AVG(price) from <your_table_name> GROUP BY brands
For more details you can follow this URL.
<http://www.techyv.com/questions/how-group-data-month-when-using-datetime-column-mysql>
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









