Hi,

I tried to write the following Query

select T1.autobrand,T1.model,max(T1.yearofconstruction)
from soldcars T1, Totalcars T2
where T1.autobrand=T2.autobrand
and T1.model=T2.model
and sum(T2.paid+T2.unpaid)<=0
group by T1.autobrand,T1.model;

but the part "and sum(T2.paid+T2.unpaid)<=0"

does not work.

but I need to have this in my where clause because I just need to know the maximum year of construction date for cars where the sum for the 2 columns in T2 is equal or lowerer as zero.

Please take into account that the column names are fictitious because I am not allowed to use the correct names. But the issue is described above.

Thanks in advance for your help