Conditional Formula with Math Function in T-SQL




declare @t table (Qty decimal(12,3),CF1 Decimal(12,3),CF2 Decimal(12,3),Flag TinyInt)
insert @t select 10,2,6,0
insert @t select 10,2,6,1


select *, Qty * (Power( CF2/CF1, flag^1 )) from @t 

 

 

http://social.msdn.microsoft.com/Forums/sqlserver/en-US/4aaeb7df-b72c-4d32-95be-807e0d487ee0/how-to-perform-this-mathematical-calculation-in-sql-server-without-using-case?forum=transactsql#05f8d1d1-5bc2-48e8-931f-45d657aa70ed

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s