如何对union连接的结果集进行再操作?

我从库里得到了4个结果集,分别是1库存,2本日销售,3本日进货,4盘点差额
我用union连接了四结果集。做视图的时候提示:视图定义中没有输出列或FROM子句中没有项目。但是我用select * from (合并结果集)报错
我想继续操作这个结果集,该怎么做呢?
---------------------------------------------------------------

select * from
(select a=1 union all
select a = 2 union all
select a = 3) as tablename

--注意:1子集必须有字段名。2合并结果集必须有表名,如tablename
---------------------------------------------------------------

select * from
(select a=1 union all
select a = 2 union all
select a = 3) as tablename where 条件.....

也要有列名或别名

Published At
Categories with 数据库类
Tagged with
comments powered by Disqus