UPDATE from one table to with content of another

  • Hi,

    I want to create a view based on two tables called A and B. The 2 tables are joined by the employeeID (A.PEmployeeID = B.PEmployeeID)

    These are the fields needed in the view.

    1) A.BACHNUMB

    2) A.PEmployeeID

    3) A.PIncomeCode

    4) A.PLineTotal

    5) A.PDescription

    6) If (A.PDepartment)<>'' then (A.PDepartment) else (B.PDepartment)

    The problem I have is that I do not know how to create the syntax in order to populate the last field.

    Can someone help me please?? I can provide more details if this is not clear..

    Thanks a lot.

  • Zaza,

    Use a CASE statement:

    (CASE A.PDepartment WHEN '' THEN B.PDepartment ELSE A.PDepartment END ) CaseCol

    Be sure to give the case column an Alias or the View won't have a name for the column. Also, be sure you're really only concerned about empty strings - you may need to modify to test for NULLS.

    HTH,

    Jeff

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply