开发过程中遇到的问题:
select count()
from t_r_fr_aststat
where d_aststat between date ‘2018-03-01’ and date
‘2018-03-31’
and c_port_code in (select A.c_port_code
from t_p_ab_port A
where rownum <= 500
order by A.c_iden)
以上SQL,执行时报缺失右括号的错误
SQL修改:
select count()
from t_r_fr_aststat
where d_aststat between date ‘2018-03-01’ and date
‘2018-03-31’
and c_port_code in ( select * from (select A.c_port_code
from t_p_ab_port A
where rownum <= 500
order by A.c_iden) B)
即可执行。
从逻辑上说,order by 应该是查询过程的最后一步,order by子句只能对最终查询结果排序。子查询中就是不能有 order by。子查询的select语句不能使用 order by子句。
子查询中不能包含order by
最新推荐文章于 2023-07-17 10:54:54 发布