-
hi guys,
i am asking out of curiosity ,
can i create a view something like this? i tried to create,but got an error
SQL> create view emp_view as select sum(sal),sum(empno) from emp;
create view emp_view as select sum(sal),sum(empno) from emp
*
ERROR at line 1:
ORA-00998: must name this expression with a column alias
SQL> select sum(sal),sum(empno) from emp;
SUM(SAL) SUM(EMPNO)
--------- ----------
23125 84951
can i create a view based on the above select ?
if there is any other way, can somebody give an example ?
thanks
-
use a column alais thats what oracle is asking you to do something like this
CREATE VIEW emp_view as SELECT SUM(sal)sumsal,
SUM(empno)sumempno from emp;
although i am not sure what sum(empno) means in your case
hope this helps
-
sorry i forgot to include this line
you can then do
select sumsal,sumempno from emp;
-
hi,
What solution provided by hrishy is ok.
When ever you use any expression, functiion in select statement when creating view or cursor you have to give
alias name.
P. Soni
-
thanks Hrishy and Psoni,it works!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|