create view
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: create view

  1. #1
    Join Date
    Feb 2001
    Posts
    114
    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

  2. #2
    Join Date
    Jan 2001
    Posts
    2,828
    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



  3. #3
    Join Date
    Jan 2001
    Posts
    2,828

    Talking

    sorry i forgot to include this line

    you can then do

    select sumsal,sumempno from emp;


  4. #4
    Join Date
    Feb 2001
    Posts
    125
    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

  5. #5
    Join Date
    Feb 2001
    Posts
    114

    Thumbs up

    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
  •  



Click Here to Expand Forum to Full Width