Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2013
    Posts
    57

    Unanswered: sql help needed.

    Can someone show me where I messed up?

    I have 2 tables: teacher, & class. here's the descriptions:

    TEACHER
    ----------------
    TEACHER_ID
    FIRST_NAME
    LAST_NAME
    TYPE_CODE
    HOME_ROOM_NUM
    PHONE_NUM
    START_DATE
    HOME_STATE
    SCHOOL_ID

    Class
    --------------------
    CLASS_ID
    CLASS_NAME
    TEACHER_ID
    MAX_SEATS_AVAILABLE

    Im trying to figure out how to count the number of classes a given teacher teaches by their ID. Here's what I have tried:
    Code:
    SELECT Teacher.last_name, Teacher.first_name, Teacher.Teacher_ID, COUNT(DISTINCT CLASS_ID) as Classes_Count 
    FROM teacher, class
    JOIN class c
    ON teacher.teacher_ID = class.Teacher_ID
    WHERE Teacher.Teacher_ID = '2'
    GROUP BY Teacher.last_name, Teacher.first_name, Teacher.Teacher_ID
    Here's what I get back:
    Code:
    ON teacher.teacher_ID = class.Teacher_ID
       *
    ERROR at line 4:
    ORA-00904: "TEACHER"."TEACHER_ID": invalid identifier
    Last edited by bwilson95; 09-23-13 at 01:02. Reason: Because I need to learn to copy/paste properly, UGH-NEED COFFEE

  2. #2
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    Code:
    FROM teacher, class
    JOIN class c
    Why did you specified class table two times?

Posting Permissions

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