Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 plz help............

Author  Topic 

wormz666
Posting Yak Master

110 Posts

Posted - 2008-10-10 : 01:33:02
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 classifi
inner 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


i want to add the weight and the revenue tons if the weight is not null if is null then the total value is the same as the revenue value..

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-10 : 02:22:22
may be this
select 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 revenuevalue
from
(
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 classifi
inner 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
Go to Top of Page
   

- Advertisement -