Hello everyone
I am trying to solve this problem which I can't find a solution of because I am new to Oracle and hope someone can guide me.
I have attached the .sql file which creates the tables and everything and from this database I need to:
Show the dlrcode-dlrname (which is the dealer code and dealer name)
I need to calculate the total number of bike sold to each dealer
and the total sales price to each dealer.
Now I managed to do a little but are not being able to do it all.
This is the query I made and if someone things there are amendmends to do please let me know.
<CODE>SELECT d.dlrname,b.DLRCODE, b.bikepurchprice, b.bikesellprice
FROM rr_bike b,rr_dealer d
where d.dlrname=d.dlrname and b.dlrcode>0;</CODE>
Thank you in advance.
Last edited by cpu2007; March 17th, 2010 at 02:17 PM.
SELECT d.dlrname,b.DLRCODE, b.bikepurchprice, b.bikesellprice
FROM rr_bike b,rr_dealer d
where d.dlrname=d.dlrname and b.dlrcode>0;
This query creates a cross product of the rr_bike records with a dlrcode > 0 and rr_dealer records with a non-null dlrname (d.dlrname is always equal to itself, except when it is null).
You have to change the WHERE clause to have a one-to-many relationship between the two tables and use grouping to calculate the totals you need.
As suggested by ideru, you may also have issues if different dealers can have the same name.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.