|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Can you help me with this query?
I have this lab and I really have no idea where to start. I read the chapter in-depth over 2 times and still am quite clueless...
The short version of the task at hand: Determine which books generate less than 55% profit and how many copies of those books were sold. I am working with (what tables I think i'll need to incorporate) two tables and the structures are as follows: BOOKS table isbn title cost retail ORDERITEMS table order# item# isbn quantity I know to get profit is AVG(retail-cost) and I know what NEEDS to be done (JOIN using the isbn column), just can't figure out the syntax. Help/hints would be greatly appreciated Last edited by theoryTim : May 5th, 2008 at 03:44 PM. |
|
#2
|
|||
|
|||
|
for simple join try this syntax and replace your actual field name
Code:
select b.f1,b.f2,b.f3,o.f1,o.f2,o.f3 from books b ,orderitems o where b.isbn=o.isbn |
|
#3
|
|||
|
|||
|
Yes I understand the syntax of the join, just to limit the results of the books that are below 55% of the profit is what is confusing me.
Something like HAVING AVG(retail-cost) < .55 This is what I don't understand - the rest of the problems of the lab were easy. |
|
#4
|
|||||
|
|||||
|
I think you need something like this:
SQL Code:
You do not need the AVG function. Cost and retail are in the BOOKS table not the ORDERITEMS table so the relationship is constant (at least as per your information) Clive |
|
#5
|
|||
|
|||
|
clivew, thank you muchly for your reply. Can you please explain to me how you came up with 1.55?
|
|
#6
|
|||
|
|||
|
Quote:
A profit of 55% requires a selling price of 1.55 * Cost Price. Cost + 55/100*Cost = Cost * 1.55 Clive |
|
#7
|
|||
|
|||
|
Thank you soooooo much clivew! That cleared everything right up for me. My head-ache may now start to dull and settle down...
Thanks man for explaining all of that to me. ![]() |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Can you help me with this query? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|