Jason Abdi
Jason Abdi

Reputation: 11

SQL Server: if 2 columns have a specific value then return a third column

I am trying to create a SQL query that does the following.

If (field-A = Value1) and (field-B = value1)
then (field-c)

So if 2 columns have a certain value I want to return the value of a third column.

Upvotes: 1

Views: 2485

Answers (2)

Andrew Leach
Andrew Leach

Reputation: 12973

select fieldc from table where fielda='value1' and fieldb='value2'

Upvotes: 2

Chris Gessler
Chris Gessler

Reputation: 23113

try this:

case 
  when field-A = @value1 and field-B = @value1 then field-C 
  else 'whatever else you want' end

Upvotes: 3

Related Questions