Re: QRY question: If field1 is null then field2
From: Steve Kass (skass_at_drew.edu)
Date: 03/24/04
- Previous message: Dan: "QRY question: If field1 is null then field2"
- In reply to: Dan: "QRY question: If field1 is null then field2"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 24 Mar 2004 13:35:43 -0500
Dan,
In SQL Server, you can write
CASE WHEN Field1 IS NULL THEN Field2 ELSE Field1 END AS [Output]
Since this particular need comes up often, there is a shorthand form:
COALESCE(Field1, Field2) AS [Output]
Steve Kass
Drew University
Dan wrote:
>Is there a way to create a column that will show the
>value of field1 unless field1 is null in which case it
>will show the value of field2? I do it all the time in
>Access but can't seem to figure out if SQL Server can do
>it as well. Any help or suggestions are geratly
>appreciatd!
>
>Here is how I do it in MS Access:
>SELECT IIf([Field1] Is Null,[Field2],[Field1]) AS [Output]
>FROM [Table];
>
>
- Previous message: Dan: "QRY question: If field1 is null then field2"
- In reply to: Dan: "QRY question: If field1 is null then field2"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|