判断某结果集为空 执行另一个语句 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
本文来自博客园,作者:忙碌在路上,转载请注明原文链接:https://www.cnblogs.com/netsa/archive/2013/03/13/2957018.html