Here is my query
Select name, thisYearSale, lastYearSale, (thisyearsale - lastYearSale) as differance from Thisyear left join LastYear on thisyear.customer = lastyear.customer.
I get all the records I want but I have one problem. When there is no matching record in the table Lastyear, I get an empty lastYearSale and differance column. Like this:
customer thisyearsale lastyearsale differance
Johnson 15.000 12.000 3.000
Smith 10.000
Simmons 12.000 14.000 -2.000
Total 37.000 26.000 1.000
The total of diference should be 11.000
Is there any way of setting a default value for a column (here the column lastyearsale) if there is no match?
tnx in advance
Mim
Select name, thisYearSale, lastYearSale, (thisyearsale - lastYearSale) as differance from Thisyear left join LastYear on thisyear.customer = lastyear.customer.
I get all the records I want but I have one problem. When there is no matching record in the table Lastyear, I get an empty lastYearSale and differance column. Like this:
customer thisyearsale lastyearsale differance
Johnson 15.000 12.000 3.000
Smith 10.000
Simmons 12.000 14.000 -2.000
Total 37.000 26.000 1.000
The total of diference should be 11.000
Is there any way of setting a default value for a column (here the column lastyearsale) if there is no match?
tnx in advance
Mim