Re: if statement?
From: Aaron Bertrand [MVP] (aaron_at_TRASHaspfaq.com)
Date: 04/27/04
- Next message: joe: "Monitor performance"
- Previous message: Zach Wells: "Re: Table Design Question"
- In reply to: Fab: "if statement?"
- Next in thread: Fab: "Re: if statement?"
- Reply: Fab: "Re: if statement?"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 27 Apr 2004 13:15:30 -0400
Assuming the values that aren't populated are NULL, and exactly one column
is always populated.
SELECT
[new column] = COALESCE(col1, col2, col3)
FROM some_table_name
Usually, it's more helpful to provide CREATE TABLE and INSERT scripts for
sample data, instead of scribblings and narrative...
-- Aaron Bertrand SQL Server MVP http://www.aspfaq.com/ "Fab" <flazzaro@tac.infostream.ca> wrote in message news:%23CO1QpHLEHA.3052@TK2MSFTNGP12.phx.gbl... > Hello; > > Im trying to put a value in a colomn depending of the value of 3 other > columns....i.e. > > > col 1 2 3 > a > b > c > in my new column i want to check the values for each row and return the > value for the row. > > i.e the final table would look like this > > > new column > a > b > c > > > Thanks. > > > >
- Next message: joe: "Monitor performance"
- Previous message: Zach Wells: "Re: Table Design Question"
- In reply to: Fab: "if statement?"
- Next in thread: Fab: "Re: if statement?"
- Reply: Fab: "Re: if statement?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|