may be thisselect transno,itedesc,[Revenue Ton],weight,total,classdesc,totalclass,[revenue total],case when [Revenue Ton]+weight is not null then [Revenue Ton]+weight else [revenue total]end AS revenuevaluefrom(Select transac.transno,itemmas.itedesc,(given * 1.13260) as [Revenue Ton],weight,case when weight = null then(given * 1.13260)else ((given * 1.13260) + weight)end as total,classifi.classdesc,p.totalclass,p.[revenue total]from transac inner join(itemmas inner join(itemdet inner join(classifi inner join (Select count(classifi.classdesc) as totalclass,sum((given * 1.13260)) as [revenue total],classifi.classdesc from classifiinner join(itemdet inner join transac on itemdet.itemno=transac.itemno)on classifi.classno=itemdet.classno group by classifi.classdesc)p on classifi.classdesc=p.classdesc)on classifi.classno=itemdet.classno) on itemmas.itemno=itemdet.itemno)on transac.itemno=itemmas.itemno )t