Sybase數據,查詢當給一個null起別名之後,再根據這個字段過濾是否爲null會有報錯。
sql語句爲:
select * from (select null as test from TestTable) t where test is null
報錯信息:
10:56:00 [SELECT - 0 row(s), 0.000 secs] [Error Code: 403, SQL State: ZZZZZ] Invalid operator for datatype op: is null type: VOID TYPE.
... 1 statement(s) executed, 0 row(s) affected, exec/fetch time: 0.000/0.000 sec [0 successful, 0 warnings, 1 errors]
解決方法:
使用convert函數轉換字段就可以了。
select * from (select null as test from TestTable) t where test is null convert(varchar(15),test) is null