How can I combine three tables in a View or a Procedure?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Emilio

    How can I combine three tables in a View or a Procedure?

    Hello everyone. I hope someone can help me with this. I have 3
    columns called EMPLOYEE_TEST, TEST_QA and EMPLOYEE_TEST_A NSWER.

    The TEST_QA table contains the following:

    TEST_QA_ID | PROC_TEST_ID | TEST_QA_QUESTIO N | TEST_QA_CORRECT
    -----------+--------------+------------------+-----------------
    3| 1|First Question | 5
    4| 2|Second Question | 1
    5| 1|Third Question | 2
    6| 3|Fourth Question | 1
    7| 3|Fifth Question | 5
    8| 3|Sixth Question | 2
    9| 3|Seventh Question | 3

    The EMPLOYEE_TEST table contains the following:

    EMPLOYEE_ID | EMPLOYEE_TEST_I D
    ------------+------------------
    3| 7

    The EMPLOYEE_TEST_A NSWER table contains the following:

    EMPLOYEE_TEST_I D | TEST_QA_ID | TEST_QA_CORRECT
    -----------------+------------+-----------------
    7| 9| 5
    7| 8| 2
    7| 6| 1

    From these three tables I can see that the employe with ID = 3 has
    answered 3 questions and two of them are correct. What I would like
    to be able to do is to represent this in a view (if possible)

    EMPLOYEE_ID | EMPLOYEE_TEST_I D | TOTAL_ANSWERS | CORRECT | WRONG
    ------------+------------------+---------------+---------+-------
    3| 7| 2| 2| 1

    Thank you in advance...

    Emilio
  • Daniel Roy

    #2
    Re: How can I combine three tables in a View or a Procedure?

    Who receives the university credits if we help, us or you?

    Daniel

    Comment

    • Ed prochak

      #3
      Re: How can I combine three tables in a View or a Procedure?

      enavarro@attglo bal.net (Emilio) wrote in message news:<7551aabf. 0312301543.4ae1 891f@posting.go ogle.com>...
      Hello everyone. I hope someone can help me with this. I have 3
      columns called EMPLOYEE_TEST, TEST_QA and EMPLOYEE_TEST_A NSWER.
      You mean three TABLES, not columns.
      Tables contain rows which are composed of columns which contain
      values.

      []
      From these three tables I can see that the employe with ID = 3 has
      answered 3 questions and two of them are correct. What I would like
      to be able to do is to represent this in a view (if possible)
      Look in your textbook for the word JOIN. Learn that before moving on
      to creating views and procedures.

      Comment

      Working...