Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 752
  • Last Modified:

iif statement/derived field in SQL

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
Tunkster
Asked:
Tunkster
  • 2
1 Solution
 
Kevin3NFCommented:
CASE myfield
    WHEN 1 then do this
    WHEN 2 do something else
    ELSE do this last thing
END
0
 
TunksterAuthor Commented:
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
 
TunksterAuthor Commented:
I stand corrected:
case (BSOL9.dbo.TW70800.TW_User_Def_text_5)
when '8810' then '8810!'
else 'nope'
end

Worked... THX!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now