Exclude records that match or many instances of a value from an oracle query
Using the query below, is it possible to exclude all instances of a Student_Number if the total instances of 'F' in STOREDGRADES.GRADE is greater than 1? Thanks so much!!
SELECT STUDENT_NUMBER,LAST_NAME,FIRST_NAME,STOREDGRADES.STORECODE, SECTIONS.TERMID, STOREDGRADES.COURSE_NAME, STOREDGRADES.COURSE_NUMBER, SECTIONS.SECTION_NUMBER, STOREDGRADES.TEACHER_NAME, STOREDGRADES.GRADE, STUDENTS.GRADE_LEVELFROM PS.STOREDGRADES STOREDGRADESLEFT JOIN PS.STUDENTS STUDENTS ON STOREDGRADES.STUDENTID = STUDENTS.ID LEFT JOIN PS.SECTIONS SECTIONS ON SECTIONS.ID = STOREDGRADES.SECTIONIDLEFT JOIN PS.COURSES COURSES ON STOREDGRADES.COURSE_NUMBER = COURSES.COURSE_NUMBERWHERE (STOREDGRADES.TERMID >= 2500) AND (STOREDGRADES.TERMID <= 2599) AND (STOREDGRADES.STORECODE IN ('Y1')) AND (STUDENTS.SCHOOLID IN (61)) AND (STUDENTS.GRADE_LEVEL = 10)AND (STUDENTS.ENROLL_STATUS = 0)AND (STOREDGRADES.GRADE IS NOT NULL)
I'm not sure, but I suspect that student_name is not in the storedgrades table, so you may want to partition by storedgrades.student_id. (NO POINTS, PLEASE!)
Sean Stuber
the partitioning clause doesn't require all of the columns to be in the same table.
my guess is student id and student number can probably be used interchangeably.
however, if they can't, the described requirement is to count Fs by student number, so that is what should drive the partitioning clause.