Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Query help
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01398766
Message ID:
01398771
Vues:
42
>Hi All,
>
>Is there a way without using a cursor to have only one Calc column instead of 3 (Calc1, Calc2 & Calc3) based on the condition below?
>
>
>select a.EDPNo, b.PVC, a.EachWeight,
>		c.VendNo, c.TermsPct, c.FrtCharge, c.FreeFrt, c.FrtAsPct, c.FrtChargePct,
>		--c.FreeFrt = 1
>		(b.PVC - (b.PVC * (c.TermsPct / 100))) as Calc1, 
>		--c.FrtAsPct = 1
>		(b.PVC + (b.PVC * (c.FrtChargePct / 100))) - (b.PVC * (c.TermsPct / 100)) as Calc2, 
>		--c.FreeFrt = 0 & c.FrtAsPct = 0
>		(b.PVC + (c.FrtCharge * a.EachWeight)) - (b.PVC * (c.TermsPct / 100))  as Calc3
>from DS1.dbo.ItemMst a join DS1.dbo.PItems b on a.EDPNo = b.EDPNo
>	 inner join DS1.dbo.VendorMst c on a.VendNo = c.VendNo
>
>
>Thanks,
>Daniel
select a.EDPNo, b.PVC, a.EachWeight,
		c.VendNo, c.TermsPct, c.FrtCharge, c.FreeFrt, c.FrtAsPct, c.FrtChargePct,
		CASE WHEN c.FreeFrt = 1 then 
		(b.PVC - (b.PVC * (c.TermsPct / 100))) 
		CASE WHEN c.FrtAsPct = 1 THEN
		(b.PVC + (b.PVC * (c.FrtChargePct / 100))) - (b.PVC * (c.TermsPct / 100))  
		CASE WHEN c.FreeFrt = 0 AND  c.FrtAsPct = 0 THEN
		(b.PVC + (c.FrtCharge * a.EachWeight)) - (b.PVC * (c.TermsPct / 100))  END as Calc
from DS1.dbo.ItemMst a join DS1.dbo.PItems b on a.EDPNo = b.EDPNo
	 inner join DS1.dbo.VendorMst c on a.VendNo = c.VendNo
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform