Unix Technical Forum

Oracle 9 SQL Query Question. Please Help...

This is a discussion on Oracle 9 SQL Query Question. Please Help... within the MySQL forums, part of the Database Server Software category; --> Lets say I had to find the products for which we had a total of $500 or more in ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 07:36 AM
Baba Boohi
 
Posts: n/a
Default Oracle 9 SQL Query Question. Please Help...

Lets say I had to find the products for which we had a total of $500 or more
in sales. I need to see the following information:

· product number

· total sales (in dollars)

· product name



So.I write this..



SQL> select orderdetails.prodnum,sum(unit*price)

2 from products,orderdetails

3 where products.prodnum=orderdetails.prodnum

4 having sum(unit*price) > 500

5 group by orderdetails.prodnum;



And it produces the correct output:



PRODNUM SUM(UNIT*PRICE)

---------- -----------

1267 968.58

1794 600

1239 30344.13

2711 399.95



Given this, how can I find the product that had the highest total sales (you
can use

your answer to the "easy" part). Output should include the same as for the
previous part, with exactly the following:



PRODNUM TOTAL

-------- ----------

1239 30344.13



Could someone help me with this? It's just a practice exercise, but I don't
know how to write the query..If you require more info, please let me know.



Thank you in advance for reading, and for your help...






Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 07:36 AM
Bill Karwin
 
Posts: n/a
Default Re: Oracle 9 SQL Query Question. Please Help...

Baba Boohi wrote:
> Given this, how can I find the product that had the highest total sales (you
> can use your answer to the "easy" part).


This sounds suspiciously like a homework question. Keep in mind that it
is frowned upon to get usenet folks to do your homework for you.

Also, your subject line indicates that this is somehow related to
Oracle. You are posting this question to a MySQL newsgroup. Though the
question isn't specific to either Oracle or MySQL. What's up?

Regards,
Bill K.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 07:36 AM
onedbguru@firstdbasource.com
 
Posts: n/a
Default Re: Oracle 9 SQL Query Question. Please Help...

I, too, think that I have seen this same question many times in various
SQL related newsgroups. If you are unable to understand these simple
concepts for finding maximum values - you are in deep trouble and
should probably consider an alternative line of work/study.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 07:36 AM
Baba Boohi
 
Posts: n/a
Default Re: Oracle 9 SQL Query Question. Please Help...

onedbguru@firstdbasource.com wrote:
> I, too, think that I have seen this same question many times in
> various SQL related newsgroups. If you are unable to understand
> these simple concepts for finding maximum values - you are in deep
> trouble and should probably consider an alternative line of
> work/study.


Such arrogance. You assume a lot.

"Better to keep your mouth shut and appear a fool, than to open it and
remove all doubt....."

- Mark Twain.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:00 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com