Quote Originally Posted by cpu2007 View Post
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;
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.