判断某结果集为空 执行另一个语句 case when 巧妙用法

SELECT  case when not exists(SELECT Cons_Date FROM sbcHisMaster WHERE HisTypeNO='L' AND ProductSN ='M7D2028')
  THEN
  (SELECT Cons_Date FROM sbcHisMaster WHERE HisTypeNO='Y' AND ProductSN ='M7D2028')
  ELSE
  (SELECT Cons_Date FROM sbcHisMaster WHERE HisTypeNO='L' AND ProductSN ='M7D2028')
END

posted @ 2013-03-13 09:38  忙碌在路上  阅读(1027)  评论(0编辑  收藏  举报