假设我有这样的查询:
Select col1,col2,(select count(smthng) from table2) as 'records' from table1
我想过滤它为“记录”列不为空.@H_301_5@
我不能做到这一点:@H_301_5@
Select col1,(select count(smthng) from table2) as 'records' from table1 where records is not null
我想出的最好的方法是将此结果集写入Table Value参数,并对该结果集进行单独查询.有任何想法吗?@H_301_5@
解决方法
只需将其移动到派生查询即可.您不能使用WHERE子句中SELECT子句中定义的列.
Select col1,records from ( Select col1,(select ..... from table2) as records from table1 ) X where records is not null;