Multiple table join

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chiume
    New Member
    • Oct 2006
    • 2

    #1

    Multiple table join

    First thank you very much for all your helps, and pls. don't laugh at my
    query :).

    Ok, this is what I am trying to do:,
    1) I am trying to get the number of employees that has completed all their
    online training within 10 days of hire
    2) All the employees that are has no exception(no pre-service training) and
    has completed their checklist within 10 days
    3) all the exception(pre-service) employees that has completed their
    training within 70 days.

    I have these tables, hipaa2006, hipaa101, hipaa201_inputs ,
    domesticviolenc e, securityawarene ss, securityawarene ss2006,
    civilrights_inp ut, and people_first_da ta.
    People_first_da ta contains all the employees we have in our database, it
    has empl_pfid col, but does not have last_modified col which all the other
    tables has.

    I have this queries:

    1) select distinct(count( empl_pfid))
    from people_first_da ta
    left outer join tbl_domesticvio lence on people_first_da ta.empl_pfid =
    tbl_domesticvio lence.employee_ pfid
    left outer join tbl_hipaa101 on
    people_first_da ta.empl_pfid=tb l_hipaa101.empl oyee_pfid
    left outer join tbl_hipaa201_in put on people_first_da ta.empl_pfid=
    tbl_hipaa201_in put.employee_pf id
    left outer join tbl_hipaa2006 on
    people_first_da ta.empl_pfid=tb l_hipaa2006.emp loyee_pfid
    left outer join tbl_securityawa reness on
    people_first_da ta.empl_pfid=tb l_securityaware ness.employee_p fid
    left outer join tbl_securityawa reness2006 on people_first_da ta.empl_pfid=
    tbl_securityawa reness2006.empl oyee_pfid
    where people_first_da ta.empl_pfid = '639846'
    and tbl_domesticvio lence.last_modi fied is not null
    and tbl_hipaa101.la st_modified is not null
    and tbl_hipaa201_in put.last_modifi ed is not null
    and tbl_hipaa2006.l ast_modified is not null
    and tbl_securityawa reness.last_mod ified is not null
    and tbl_securityawa reness2006.last _modified is not null

    2) ( I tried union, but i only wanted one number)
    select count(last_modi fied) as date1 from tbl_hipaa2006
    union
    select count(last_modi fied) as date2 from tbl_hipaa101

    Your help will be highly appreciated.
  • sashi
    Recognized Expert Top Contributor
    • Jun 2006
    • 1749

    #2
    Hi there,

    Kindly refer to below attached link, use SQL JOIN, hope it helps. Good luck & take care.

    SQL is a standard language for storing, manipulating and retrieving data in databases.

    Comment

    Working...