Results 1 to 7 of 7

Thread: Sql help!

  1. #1
    Join Date
    May 2012
    Posts
    3

    Unanswered: Sql help!

    So i'm trying to run the following sql but the output is not as anticipated. I would like to, instead of have both in one column, separate the views from the aliases. i'd appreciate your help guys =)

    db2 "select rtrim(tabschema)||'.'|| rtrim(tabname) as Schema_View from syscat.tables where type= 'V' UNION ALL select rtrim(tabschema)||'.'|| rtrim(tabname) as Schema_Alias from syscat.tables where type='A'" |more

  2. #2
    Join Date
    Apr 2012
    Posts
    1,034
    Provided Answers: 18
    Why not include the 'type' column in the result set , it will show 'V' or 'A' to distinguish between views and aliases?

  3. #3
    Join Date
    May 2012
    Posts
    3
    Yes, I have done that but my goal was really to have one view column and one alias column. it's for a project in school and our professor would like us to figure out how to do it.

  4. #4
    Join Date
    Apr 2012
    Posts
    1,034
    Provided Answers: 18
    in that case , think about having 2 separate columns and decide what should be in the "view" column when the item is an alias, and what should be in the "alias2 when the item is a view. Think about what the CASE expression might do for you. If you get told the answer, how will you learn?

  5. #5
    Join Date
    Oct 2009
    Location
    221B Baker St.
    Posts
    486
    How much "figuring" is involved when someone posts the answer . . . ?

  6. #6
    Join Date
    Oct 2009
    Location
    221B Baker St.
    Posts
    486
    Follow on:

    I suspect that one of the main purposes for this exercise is the instructor wanted to encourage the class to "figure it out" on their own and not ask "how can i do this".

    Very cool that db2mor is providing guidance without actually slinging code in the replies

  7. #7
    Join Date
    May 2012
    Posts
    3
    well after an hour of trying many different methods, i searched for forums, ran across this, and asked for help. i'm really done "figuring" it out and just want an answer =\!

Posting Permissions

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