Home Forums SQL Server 2008 T-SQL (SS2K8) How to perform mathematical formula without using case. RE: How to perform mathematical formula without using case.

  • The simplest version I could think of.

    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)

    FROM @t

    EDIT: Unless someone proves me wrong, it cannot be made without functions or a CASE statement. At least not in SQL Server (other languages don't need a POWER function).

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2