QRY question: If field1 is null then field2

From: Dan (dannyjoered_at_aol.com)
Date: 03/24/04

  • Next message: Steve Kass: "Re: QRY question: If field1 is null then field2"
    Date: Wed, 24 Mar 2004 10:25:11 -0800
    
    

    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];


  • Next message: Steve Kass: "Re: QRY question: If field1 is null then field2"

    Relevant Pages

    • Re: "evil" OR?
      ... Columnist, SQL Server Professional ... SELECT Field1, Field2, etc ... WHERE Field5 IN ...
      (microsoft.public.sqlserver.programming)
    • Re: How to find Minimum of four fields
      ... SELECT Id, Field1, Field2, "PhoneCost" AS CostType, PhoneCost AS CostAmount ...
      (microsoft.public.access.gettingstarted)
    • Re: How to find Minimum of four fields
      ... Let's assume you currently have a table with Id, Field1, Field2, WebCost, ... PhoneCost, StoreCost, and ShowCost. ...
      (microsoft.public.access.gettingstarted)
    • Re: Copying a Field
      ... Since Field1 has no value on a new record, niether will Field2. ... > field is the primary key and a second field will for the some of the time ... > Debbie D. ...
      (microsoft.public.access.forms)
    • Re: 30 tables I need the Same 5 fields from wach of them!!!
      ... You need a union query ... ... UNION SELECT Field1, Field2 FROM SecondTable ... GlobalSign digital certificate is a forgery and should be deleted without ...
      (microsoft.public.access.queries)