Creating table from 3 diffrent tables with conditions

  • 1)Assuming Process, Organization and Department tables all exist. please show me how you would create table(s) as it relates to these 3 existing tables/keys (OrganizationID, DepartmentID and ProcessID); Facts: In each organization there can be 1 or more departments and within each department there can be 1 or more processes.

    2)Status lookup values are configured by organization/departments

    3)Status lookup values created by the organization/department are then assign to different Process

    4)Be able to inactivate or activate these dropdown values

  • Can you post what you've attempted already? How about sample rows of data to go along with it? Is there a specific problem that you've encountered while trying to design this solution out?

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • Create table #Status as

    (Select OrgName, OrgID, DeptName, DeptID, ProcessName ProcessID from #Org, #Dept, #process where #process.DID = #Dept.DID and #Dept. OrgID = #Org. OrgID)

  • Are you trying to create a temp table? The #prefix in front of your table names makes them temp tables...

    Anyways, if you need to create a table from a query, you can use the INTO clause in the query. This can load the results of the query into a permanent or temp table. My example below uses a temp table since that's how your other tables were named. It can be changed if need be.

    SelectOrgName

    , OrgID

    , DeptName

    , DeptID

    , ProcessName

    , ProcessID

    INTO #NewTable

    from#Org

    INNER JOIN #Dept ON #Dept.OrgID = #Org.OrgID

    INNER JOIN #process ON #process.DID = #Dept.DID

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • Thank you so much I will work on it.

Viewing 5 posts - 1 through 4 (of 4 total)

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