Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 11-01-2010, 02:11 PM   #1
BSleazy
Confirmed User
 
Industry Role:
Join Date: Aug 2002
Location: USA
Posts: 6,721
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)
__________________
icq 156131086
BSleazy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-01-2010, 02:17 PM   #2
georgeyw
58008 53773
 
georgeyw's Avatar
 
Industry Role:
Join Date: Jul 2005
Location: Australia
Posts: 9,864
Select type, avg(price) from book where paperback = 'y' group by type
georgeyw is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-01-2010, 02:17 PM   #3
Senior_Spank
Registered User
 
Join Date: Aug 2006
Posts: 63
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
Senior_Spank is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-01-2010, 02:17 PM   #4
woj
<&(©¿©)&>
 
woj's Avatar
 
Industry Role:
Join Date: Jul 2002
Location: Chicago
Posts: 47,882
need to "GROUP BY" something
__________________
Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager
woj is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-01-2010, 02:18 PM   #5
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,109
Quote:
Originally Posted by BCyber View Post
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
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-01-2010, 02:19 PM   #6
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,109
Quote:
Originally Posted by georgeyw View Post
Select type, avg(price) from book where paperback = 'y' group by type
lol, you're just a touch quicker than I am ;p
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-01-2010, 02:23 PM   #7
georgeyw
58008 53773
 
georgeyw's Avatar
 
Industry Role:
Join Date: Jul 2005
Location: Australia
Posts: 9,864
Quote:
Originally Posted by sarettah View Post
lol, you're just a touch quicker than I am ;p
haha - I refreshed and saw your reply
georgeyw is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-01-2010, 02:24 PM   #8
Tempest
Too lazy to set a custom title
 
Industry Role:
Join Date: May 2004
Location: West Coast, Canada.
Posts: 10,217
ha ha ha.. was going to post the same answer as everyone else when there were no replies and then there were 6
Tempest is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-01-2010, 02:29 PM   #9
Jason Voorhees
So Fucking Banned
 
Industry Role:
Join Date: Jul 2010
Location: Camp Crystal Lake.
Posts: 843
Select type, avg(price) from book where paperback = 'y' group by type
Jason Voorhees is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-01-2010, 02:30 PM   #10
Jason Voorhees
So Fucking Banned
 
Industry Role:
Join Date: Jul 2010
Location: Camp Crystal Lake.
Posts: 843
Oh... Oh shit... Am I too late?
Jason Voorhees is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-01-2010, 02:40 PM   #11
BSleazy
Confirmed User
 
Industry Role:
Join Date: Aug 2002
Location: USA
Posts: 6,721
Dam that was a lot of replies fast...thanks
__________________
icq 156131086
BSleazy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-01-2010, 03:04 PM   #12
myneid
Confirmed User
 
myneid's Avatar
 
Industry Role:
Join Date: Jan 2003
Location: Los Angeles
Posts: 736
truncate Books;
__________________
Tanguy 0x7a69 inc. Programmer/President/CEO
http://www.0x7a69.com
A Leader in Programming since 1996
PHP, Ruby on Rails, MySQL, PCI DSS, and any Technical Consulting
myneid is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-01-2010, 03:09 PM   #13
grumpy
Too lazy to set a custom title
 
grumpy's Avatar
 
Join Date: Jan 2002
Location: Holland
Posts: 9,870
Quote:
Originally Posted by myneid View Post
truncate Books;
not so funny, apparently the guy isn't to familiar with MYSQL
__________________
Don't let greediness blur your vision | You gotta let some shit slide
icq - 441-456-888
grumpy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-01-2010, 03:35 PM   #14
buran
Confirmed User
 
Join Date: Mar 2002
Location: how'd I get here?
Posts: 264
Ohshit, can I get GFY to do my CS101 homework now? Werd!
__________________
[this signature intentionally left blank]
buran is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-01-2010, 03:43 PM   #15
0x7noah
Registered User
 
Join Date: Mar 2010
Posts: 2
Quote:
Originally Posted by BCyber View Post
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.
0x7noah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-01-2010, 03:45 PM   #16
sextoyking
Confirmed User
 
Industry Role:
Join Date: Dec 2001
Location: Portland, OR.
Posts: 6,034
Quote:
Originally Posted by 0x7noah View Post
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
__________________
ICQ: 52344098
--------------------------------------
50% Commissions on all Product Sales. http://www.wishing.com/money
sextoyking is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-01-2010, 03:48 PM   #17
0x7noah
Registered User
 
Join Date: Mar 2010
Posts: 2
Quote:
Originally Posted by sextoyking View Post
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
0x7noah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-01-2010, 04:13 PM   #18
Jason Voorhees
So Fucking Banned
 
Industry Role:
Join Date: Jul 2010
Location: Camp Crystal Lake.
Posts: 843
I don't think Bcyber is that stupid.
Jason Voorhees is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-01-2010, 05:13 PM   #19
BSleazy
Confirmed User
 
Industry Role:
Join Date: Aug 2002
Location: USA
Posts: 6,721
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.
__________________
icq 156131086
BSleazy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-05-2010, 06:34 PM   #20
BSleazy
Confirmed User
 
Industry Role:
Join Date: Aug 2002
Location: USA
Posts: 6,721
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.
__________________
icq 156131086
BSleazy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-05-2010, 06:36 PM   #21
BSleazy
Confirmed User
 
Industry Role:
Join Date: Aug 2002
Location: USA
Posts: 6,721
nevermind...soon as i posted that i came across it in my book.
__________________
icq 156131086
BSleazy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks
Thread Tools



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.