• dirtyshorellc (8/9/2012)


    Hello,

    I am new to SQL and have been asked to perform a query of our Dispatch database. Although I am able to pull most of the information I need I am having trouble with the following.

    The following queries work seperately on their own:

    SELECT unit_status_datetime AS UnitLeftSceneDateTime

    FROM unit_status_hist

    WHERE cad_command_code = 'EH'

    SELECT unit_status_datetime AS UnitLeftSceneDateTime

    FROM unit_status_hist

    WHERE cad_command_code = 'AH'

    Problem is I need to include these in a query that will be selecting multiple columns along with these.

    Is there a way to specify multiple aliases for a single column a retrive the data I need?

    Thank you for your time!

    Chris Abbott

    Not knowing how these are being used in the overall query, hard to give you a working answer.

    Looking at these queries as is, the follow are equivalent:

    SELECT unit_status_datetime AS UnitLeftSceneDateTime

    FROM unit_status_hist

    WHERE cad_command_code = 'EH' OR cad_command_code = 'AH';

    SELECT unit_status_datetime AS UnitLeftSceneDateTime

    FROM unit_status_hist

    WHERE cad_command_code in ('EH','AH');

    Perhaps if you showed us what it is you are trying to accomplish we could give you a better answer.