Using an OR operator in a SQL statement

Posted on 2005-04-21
Last Modified: 2010-03-19
Bit of a mental block on this!!

I have a function with a select statement in it. One of the tables has two fields in in "Transport_driven_by" CHAR(3) and "Transport_Driver" BIT.

I want to return a 1 in my select statement if EITHER Transport is not null OR Transport_driver = 1 - Otherwise return a Zero.


Select placement_ID, Booking_ID (ETC), [statement re above] as Transport, Person_ID (ETC) from tbl_placements

Can anyone help please?
Question by:pauldonson
    LVL 23

    Accepted Solution

    Select placement_ID, ......,
         CASE WHEN Transport IS NOT NULL OR Transport_driver = 1 THEN 1 ELSE 0 END AS Transport, Person_ID
    FROM tbl_placements

    Author Comment

    Perfect, thanks for the quick response.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    In this article—a derivative of my blog post (—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
    For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
    Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
    Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now