Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2013
    Posts
    3

    Unanswered: Using column Alias Names

    If I have 2 columns in a table Like:

    Number1 Number2
    1 2
    3 4
    5 6

    How do I add these columns up using the alias name? For example,

    SELECT
    Number1 as Num1,
    Number2 as Num2,
    Num1+Num2 as Sum
    FROM
    Table

    Is this possible?
    Thanks for your help

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    It isn't strictly possible to manipulate the data in columns using the alias name, although if your version of Oracle supports them you could fudge it by using a materialized sub-query which might be close enough for some purposes.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >How do I add these columns up using the alias name?
    What is the advantage to using an approach that does not work & avoid using one that does work?


    SELECT
    Number1 as Num1,
    Number2 as Num2,
    Number1+Number2 as Sum
    FROM
    Table1
    Last edited by anacedent; 03-27-13 at 20:02.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •