Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2012
    Posts
    1

    Unanswered: sql query--need help

    Hi fellow developers,

    I have to implement below mentioned design using SQL queries(DB2 Database).Pls help with your suggestions.

    The base table 'BA' has an attribute (say X), which has two values - 'active' and 'inactive'. table BA is to be joined with table BA_ALT(which is identical to BA, but it stores 1 days history data). And the data is to be loaded in the target table 'tgt'. And the condtion to be implementated is - if the value of X is 'active', then the row must be loaded directlt in the tgt, but if the x='inactive', then some transformation logic is to be implementated and the row is to be loaded.

    Now my query is , can this be implemented with 2 insert statements, in one using where x='active' in the join condition and in second insert , using where x='inactive'? will this work? Or is there a better way of implementin this if else situation?

    PS-- the OS is unix. The queries will be executed in a unix scrpit.

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by indigo3 View Post
    will this work?
    Yes.

    Quote Originally Posted by indigo3 View Post
    is there a better way of implementin this if else situation?
    You might try using the CASE expression.

Posting Permissions

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