DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: column as a query? & order by

  1. #1
    Join Date
    Feb 2000
    Posts
    24
    2 quick questions:

    First, is it possible to create a table that has a column that is a query? I know i can do it in a view. IE: select column1, column2, (select avg(othercolumn) from othertable) as column3. Is it possible to have that in an actual table?

    Also, if i'm sorting by varchar2 , it sorts numbers like (1,10,11,2,21,22).. is there anyway to have varchar2 sort numbers normally? or is there some other data type that allows for non-numeric data that will sort normally?

    Thank You.

  2. #2
    Join Date
    Mar 2001
    Location
    Reading, U.K
    Posts
    598
    if u want something like this then it works,

    select a.deptno, a.dname, (select avg(b.sal) from emp b where a.deptno = b.deptno) hhh from dept a;

    DEPTNO DNAME HHH
    ---------- -------------- ----------
    10 ACCOUNTING 2916.66667
    20 RESEARCH 2175
    30 SALES 1566.66667
    40 OPERATIONS

    Cheers!
    Cheers!
    OraKid.

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