I'm working on my first SQL case statement - and unsure how to do this.
I have two different columns of data, one is for drive A, the other drive B.
I want to select data from drive A for display when drive A is active, and display data from drive B when it is active.
I'm having trouble understanding how to use the case statement as a part of the select statement.
I know that the case statement returns a boolean value, but I'm unsure of how to incorporate this into my Select expression. Right now I have:
SELECT t_stamp AS DateTime,
CASE WHEN DriveAActive
THEN DriveA_TorqueActual
ELSE DriveB_TorqueActual
I don't see a good reference on this topic - any pointers?
WHERE DriveA='active' AND DriveB='active';not a case expressionENDand an alias for theCASEexpression.DriveAActive? Your espression will work with a BOOLEAN or INT (where 0 is FALSE, anything else is TRUE).CASE WHEN DriveAActive = 'yes'