Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2010
    Posts
    11

    Unanswered: How do you create a column?

    How do you create a column for your select statements?

  2. #2
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    do you mean something like this:
    Code:
    SELECT real_table_column,
           'some_value' as dynamic_column
    FROM the_table_with_no_name

  3. #3
    Join Date
    Oct 2010
    Posts
    11
    The only columns I can create are from the tables themselves, like; groupid, titleid, for example. For example, If wanted a select statement that shows a number of trips a certain person made and all Ive got is 'trips' and 'persons' and I want want a column/headline that says "Number of Trips" with the number of trips below. Thats a crap example but how would I create that headline "Number of Trips"? I can only put 'trips' and 'persons' at the top.

  4. #4
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    Code:
    SELECT trips as "Number of Trips", 
           persons
    FROM the_table_with_no_name

  5. #5
    Join Date
    Oct 2010
    Posts
    11
    Thanks for that. So thats like renaming it. Do you know how to name columns without renaming it? For example; if youve only got 'distance', and you want to create a new column called 'Cost' that is the 'distance' multipled by something.

  6. #6
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >you want to create a new column called 'Cost' that is the 'distance' multipled by something.
    It is a BAD design to do as proposed.
    A derived value can be computed in SELECT statement.
    In an Invoice_detail table some may want to store line_cost as price * qty
    what can occur is that later either price or QTY changes but the line_cost does not get recomputed.

    Do NOT do store computed or derived values in the table; ever!
    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.

  7. #7
    Join Date
    Oct 2010
    Posts
    11
    Im sorry, I dont really understand you.

  8. #8
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    what problem are you trying to solve?

    how will an independent observer know when the correct solution has been posted?
    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.

  9. #9
    Join Date
    Mar 2007
    Posts
    623
    Quote Originally Posted by mbrother64 View Post
    Thanks for that. So thats like renaming it. Do you know how to name columns without renaming it? For example; if youve only got 'distance', and you want to create a new column called 'Cost' that is the 'distance' multipled by something.
    Fortunately, SELECT statement accepts expressions in SELECT clause, as stated in SQL Reference book. It is available with other Oracle documentation e.g. online on http://tahiti.oracle.com/
    Code:
    SELECT distance * something "Cost"
    FROM the_table_with_no_name
    Just for certainty, which reporting tool are you referring to (Forms, Crystal Reports, Business Objects)? Because, shammat here just demonstrated the abilities of simple SQL combined with sqlplus output (although some other tools could display it too - I am not so familiar with them).

Posting Permissions

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