This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi All, Just wondering if this is a possibility. I need to do a pretty complicated select statement, and one of the things I need to do is select a time value. The problem I have is, I need to use the time value in Column A, only if the value in Column B is null, if the value in Column B is not null, I need to use its value. I can't just select both values and then determine what to use AFTER the query, because I also need to sort on this value. I have never done this sort of thing and wonder if it is doable in SQL or in a stored procedure. In psuedo code, here is what I want to do:
Select x, y, z, (A as duration if B isNull OR B as duration if B is not null) from myTable ORDER BY duration;
then hoping I get a result set with several rows like this, ordered by the duration value:
xval, yval, zval, duration (where the value of duration could have come from either column A or column B).