Select statement

anonymous_at_discussions.microsoft.com
Date: 05/11/04


Date: Tue, 11 May 2004 12:36:40 -0700

Lookup up COALESCE in BOL.

For Example:
SELECT ( COALESCE( CompanyName, [Last Name] + [First
Name] ) ) AS MyColumn
FROM MyTable

>-----Original Message-----
>This is regarding a SQL Select statement
>I have a table with 3 columns First Name, Last Name ,
>CompanyName
>I want a result of companyName, using a select statement
>with the condition that
>if CompanyName is Null then result should have LastName +
>FirstName
>
>something like
>if CompanyName is null Then
>Select LastName + FirstName from Table
>else
>Select CompanyName from Table
>
>Can this if..else be used in a single Select statement?
>.
>



Relevant Pages

  • Re: customize sort of search form
    ... I would think that something like the SQL below would work. ... ORDER BY InStr(1,CompMain.CompanyName,[What Company Prompt],1), CompanyName ... > FROM CompMain ... Now, when I run this, it prompts me ...
    (microsoft.public.access.queries)
  • Re: Combo Box Display
    ... I suspect a problem in the SQL you are building. ... " ORDER BY CompanyName" ... Dim strSource as String ... populate cboContact with multiple names, ...
    (microsoft.public.access.gettingstarted)
  • Re: Query pulls data from wrong table field
    ... Perhaps you could you post the SQL? ... on companyname from Inquiries to Customers, ... "Brendan Reynolds" wrote: ... that table into your query to include the real company name field. ...
    (microsoft.public.access.queries)
  • SqlCE and LIKE Sql Statement
    ... I am trying to get the following LIKE statement to work in SQL CE: ... SELECT CompanyName FROM Customers WHERE CompanyName NOT LIKE ...
    (microsoft.public.pocketpc.developer)
  • Re: SqlCE and LIKE Sql Statement
    ... Take a look at the SQL CE 2.0 help file. ... in the LIKE statement is not support in SQL CE 2.0. ... > SELECT CompanyName FROM Customers WHERE CompanyName NOT LIKE ...
    (microsoft.public.pocketpc.developer)