Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Sql Server Programming

where's the ( IF ) in sql server 2000


Hi there,

Im writing a query in which I wan to calculate a colum based on the values
of other columns, so what I wanted to do was something like

IF colType=3 then   colRecovery * .234  ELSE  colReverb * 0.6

How can I do this ??

Cheers

Hi

There is no IF in SQL Server, you need CASE:

SELECT YourField =
  CASE ColType
    WHEN 3 THEN colRecovery * 0.234
    ELSE colReverb * 0.6
END

J.

Jason Sweby
Software Development Manager,
Carval Computing Limited, Plymouth, UK www.carval.co.uk

Payroll - HR - T&A - Access Control

"New Bee" <p@p.com> wrote in message

news:u4hthpsoHHA.4188@TK2MSFTNGP02.phx.gbl...

Try:

SELECT
    CASE WHEN colType=3 THEN colRecovery * .234  ELSE  colReverb * 0.6
 END
from
    MyTable

--
   Tom

----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON   Canada
https://mvp.support.microsoft.com/profile/Tom.Moreau

"New Bee" <p@p.com> wrote in message

news:u4hthpsoHHA.4188@TK2MSFTNGP02.phx.gbl...
Hi there,

Im writing a query in which I wan to calculate a colum based on the values
of other columns, so what I wanted to do was something like

IF colType=3 then   colRecovery * .234  ELSE  colReverb * 0.6

How can I do this ??

Cheers

-----------------------------------------------Reply-----------------------------------------------

Use CASE or COALESCE

"New Bee" <p@p.com> wrote in message

news:u4hthpsoHHA.4188@TK2MSFTNGP02.phx.gbl...

THANK YOU ALL

"New Bee" <p@p.com> wrote in message

news:u4hthpsoHHA.4188@TK2MSFTNGP02.phx.gbl...

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc