关于网友提出的“oracle里关于sql查询结果建表的问题”问题疑问,本网通过在网上对“oracle里关于sql查询结果建表的问题”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题:oracle里关于sql查询结果建表的问题
描述:
oraclesqlpl/sql
用的是PL/SQL
select t.countycode, count(*)
from result t
group by t.countycode
having count(*) > 1
order by countycode asc
这个是我的查询结果,完全正常
然后要把查询结果建表
create table aaa as (select t.countycode, count(*) as countycodecount
from result t
group by t.countycode
having count(*) > 1)
设置count(*)给个中间量也能成功,但是,()里的sql语句不能加order by countycode asc,否则就显示缺括号等错误
解决方案1:
create table aaa as select t.countycode, count(*) as countycodecount
from result t
group by t.countycode
having count(*) > 1 order by countycode asc
这样就行了
解决方案2:
提醒一点,虽然排序后很可能会按这个顺序保存,但并不保证。需要排序最好在查询的时候加order by来控制
以上介绍了“oracle里关于sql查询结果建表的问题”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/953941.html