decode这样用语法不对。
你试一下这个:
decode((select 1 from dual where exists(select carbasic.carid from carbasic)),1,'YES','NO')
你试一下这个:
decode((select 1 from dual where exists(select carbasic.carid from carbasic)),1,'YES','NO')
除非你在子查询里加上条件。
decode里面能用if then么?没听说过。
if then是pl/sql,这是标准sql语句,不能用的。
Decode(if exists(select carbasic.carid from carbasic) then ,
'yes','no')
在这一句中如果carbasic表有n条记录,那么前面结果集中有m条记录的话,
那么exists为true,decode之后得到yes,那么最后这m*n条记录中gonder这一列就应该全部是yes。如果carbasic表没有记录,那么最后应该得不到任何记录。我不知道你得到这样的结果对不对,只是用这个sql语句只能得到这样的结果。
建议贴主考虑你要达到的目的而重新设计该语句。一家之言,欢迎批评。