SQL Language (MOSC)

MOSC Banner

Query to find group that has no representative value in that group

edited Apr 11, 2015 11:38AM in SQL Language (MOSC) 2 commentsAnswered ✓

I'm trying to come up with a query that will allow me to identify groups of rows that do not contain a row with a certain value.  A simple example might be a class table and student table as follows:

create table class (class_id varchar2(2));

create table student (student_id number(38),class_id varchar2(2),a_student varchar2(3));

with rows:

insert into class values ('A');

insert into class values ('B');

insert into student values (1,'A','yes');

insert into student values (2,'A','no');

insert into student values (3,'B','no');

insert into student values (4,'B','no');

I would like to find which class does not have a straight a student in it.  The result should look like this:

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center