User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 391,912 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,662 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser:
Views: 1566 | Replies: 2
Reply
Join Date: Oct 2006
Posts: 88
Reputation: dami06 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
dami06 dami06 is offline Offline
Junior Poster in Training

Help MySQL query's

  #1  
Feb 19th, 2007
Hi,
I am trying to understand MySQL as i am new to this and i have a few queries I am having problems with and I was wondering if anyone can help me with it.. How would you solve this problem using the Select, from, where etc commands.
For example if you were to Find out what the average cost of all the books in a book table is, how would you write it.. and also how to find out which book cost the MOST in a book table, how would you write it.. I have tried to write what i have thought but its not giving me any answer at all.. I am using MySQL query.. Thank you so much in advance for your help
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2005
Location: Manchester, UK
Posts: 481
Reputation: pty is on a distinguished road 
Rep Power: 3
Solved Threads: 31
pty's Avatar
pty pty is offline Offline
Posting Pro in Training

Re: MySQL query's

  #2  
Feb 19th, 2007
Originally Posted by dami06 View Post
Hi,
I am trying to understand MySQL as i am new to this and i have a few queries I am having problems with and I was wondering if anyone can help me with it.. How would you solve this problem using the Select, from, where etc commands.
For example if you were to Find out what the average cost of all the books in a book table is, how would you write it.. and also how to find out which book cost the MOST in a book table, how would you write it.. I have tried to write what i have thought but its not giving me any answer at all.. I am using MySQL query.. Thank you so much in advance for your help


You should be using the avg and max functions.

So to get the average price

  select avg(price) from books;

or the most expensive
  select title, max(price) from books group by title order by max desc


/you may need to alter these slightly for mysql - i use postgresql these days
Last edited by pty : Feb 19th, 2007 at 10:44 am.
Note to self... pocket cup
Reply With Quote  
Join Date: Oct 2006
Posts: 88
Reputation: dami06 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
dami06 dami06 is offline Offline
Junior Poster in Training

Re: MySQL query's

  #3  
Mar 14th, 2007
Thank u so much...sorry for late reply
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb MySQL Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the MySQL Forum

All times are GMT -4. The time now is 7:50 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC