Saturday, January 31, 2015

selecting colums from different table

Hi, I have to say that you are using a strange (to me) logic.


However, I can suggest to use a CASE..WHEN (http://ift.tt/1yYchHu):



SELECT
firstname,
coursetitle,
CASE
WHEN coursecompleted=1 THEN 1
ELSE NULL
END AS pass,
CASE
WHEN coursecompleted=0 THEN 1
ELSE NULL
END AS fail
FROM test




No comments:

Post a Comment