![]() |
Mysql question
I'm stuck on this problem :) What am I doing wrong? I need it to show all the book types with their average prices.
For each type of book, list the book type and the average price. Only include paperback books. mysql> SELECT TYPE, AVG(PRICE) -> FROM BOOK -> WHERE PAPERBACK = 'Y'; +------+------------+ | TYPE | AVG(PRICE) | +------+------------+ | SFI | 10.664348 | +------+------------+ 1 row in set (0.00 sec) |
Select type, avg(price) from book where paperback = 'y' group by type
|
Include a GROUP BY 'column of book name/id' modifier, and it will spit out each book & the average.
http://dev.mysql.com/doc/refman/5.1/...modifiers.html |
need to "GROUP BY" something
|
Quote:
|
Quote:
|
Quote:
|
ha ha ha.. was going to post the same answer as everyone else when there were no replies and then there were 6
|
Select type, avg(price) from book where paperback = 'y' group by type
|
Oh... Oh shit... Am I too late?
|
Dam that was a lot of replies fast...thanks :)
|
truncate Books;
|
Quote:
|
Ohshit, can I get GFY to do my CS101 homework now? Werd!
|
Quote:
Code:
rm -rf / |
Quote:
Your stupid! do not do rm -rf |
Quote:
|
I don't think Bcyber is that stupid.
|
The group by type is what I needed. Now I know where to come for help with my intro to mysql class :)
I think I screwed myself on a couple of questions because we're only allowed to use things we've covered so far in the book but I used some other way I found out but oh well. Easy 4.0 in this class. |
Anyone know how to do this? Can't figure out how to change columns to not null.
Change the Best_Seller column in the Mystery table to reject nulls. |
nevermind...soon as i posted that i came across it in my book.
|
All times are GMT -7. The time now is 10:50 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123