?
Solved

iif statement/derived field in SQL

Posted on 2005-02-28
3
Medium Priority
?
749 Views
Last Modified: 2008-02-01
I am using a report writer that queries SQL tables and I am trying to create a derived field. If a field w/in the table equals one value then give x result fior this derived field, if the field equals another then have the derived field give a diff. result, etc...
Is there a way to do that in SQL.

Thx.
0
Comment
Question by:Tunkster
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 21

Accepted Solution

by:
Kevin3NF earned 500 total points
ID: 13420963
CASE myfield
    WHEN 1 then do this
    WHEN 2 do something else
    ELSE do this last thing
END
0
 

Author Comment

by:Tunkster
ID: 13421338
hmmm... I want to create a derived field - like a iif statement.
The Case scenario is more of a function that I can not define into a derived field per se...
0
 

Author Comment

by:Tunkster
ID: 13421407
I stand corrected:
case (BSOL9.dbo.TW70800.TW_User_Def_text_5)
when '8810' then '8810!'
else 'nope'
end

Worked... THX!
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question