现实中我们经常使用 select * from (select name,count(*) counter from table1 group by name) where counter>1 或用r_id替代rownum来执行查询之类的语句。 事实证明count(*)、rownum等伪列的别名是可以用来执行查询的。
其实作为子查询时都是可以用的。比如你的 select * from (select name nam,count(*) counter from table1 group by name) where counter>1 and nam='liujia';这也是可以用的。 总之别名的使用可以分析,遵循后置原则,即查询时不会根据别名查询,查询后才会把结果传给别名,然后当成一个虚拟视图显示给用户
select * from
(select name,count(*) counter from table1 group by name)
where counter>1
或用r_id替代rownum来执行查询之类的语句。
事实证明count(*)、rownum等伪列的别名是可以用来执行查询的。
select * from
(select name nam,count(*) counter from table1 group by name)
where counter>1 and nam='liujia';这也是可以用的。
总之别名的使用可以分析,遵循后置原则,即查询时不会根据别名查询,查询后才会把结果传给别名,然后当成一个虚拟视图显示给用户