Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 15th, 2007, 12:16 PM
Registered User
 
Join Date: Jan 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default IFF statement in SQL

Hi All I'm new SQL Been using Access for a number of years. I wanted to know how to convert a Iff Statements into SQL.

My Iff Statement

DAYRATER: IIf([EmployeeTypeId]=12 Or [EmployeeTypeId]=10,([SumOfbillable_hours]/9),"NA")

If any one can point me in the right direction that would be great.

Many Thanks

Scott
 
Old January 15th, 2007, 01:13 PM
Authorized User
 
Join Date: Oct 2005
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can use the CASE statement for this:

CASE WHEN [EmployeeTypeID] IN (10, 12) THEN [SumOfBillable_Hours] / 9,
     ELSE 'NA' END

Just make sure that the data type that will be returned for both cases are compatible to each other. Otherwise you will get an error message.

SQL Server Helper
How well do you know SQL? Find out with the free test assessment from SQL Server Helper!!!
http://www.sql-server-helper.com/free-test/default.aspx

Got a SQL Server Question? Ask us here: http://www.sql-server-helper.com/forums/default.asp





Similar Threads
Thread Thread Starter Forum Replies Last Post
iff statement not working barmanvarn BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 3 January 23rd, 2009 04:25 PM
IFF () in SQL ayazhoda Access 5 July 17th, 2007 05:52 AM
convert a SQL Statement from MS Access to a SQL Corey Access 6 March 28th, 2007 12:33 PM
Would this be a IFF then Statement Corey Access 7 November 2nd, 2006 03:18 PM
Function Iff in VB 6.0 daninoj Beginning VB 6 2 January 17th, 2005 01:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.