Question
********************************************************************************************** Practice #HAVING /* Having: draw result tables R(A, B) Select A From R Group by A Select A From R Group by A Having
********************************************************************************************** Practice #HAVING /* Having: draw result tables R(A, B) Select A From R Group by A Select A From R Group by A Having count(*)>2 Select A From R Group by A Having max(B)<4 *>
10) Write a query to find the Colleges with fewer than 5 applications
DROP DATABASE IF EXISTS college_application;CREATE DATABASE college_application;USE college_application;drop table if exists Student;drop table if exists College;drop table if exists Apply;/* Create the schema for our tables */create table College(cName text, state text, enrollment int);create table Student(sID int, sName text, GPA real, sizeHS int);create table Apply(sID int, cName text, major text, decision text);insert into Student values (123, 'Amy', 3.9, 1000);insert into Student values (234, 'Bob', 3.6, 1500);insert into Student values (345, 'Craig', 3.5, 500);insert into Student values (456, 'Doris', 3.9, 1000);insert into Student values (567, 'Edward', 2.9, 2000);insert into Student values (678, 'Fay', 3.8, 200);insert into Student values (789, 'Gary', 3.4, 800);insert into Student values (987, 'Helen', 3.7, 800);insert into Student values (876, 'Irene', 3.9, 400);insert into Student values (765, 'Jay', 2.9, 1500);insert into Student values (654, 'Amy', 3.9, 1000);insert into Student values (543, 'Craig', 3.4, 2000);insert into College values ('Stanford', 'CA', 15000);insert into College values ('Berkeley', 'CA', 36000);insert into College values ('MIT', 'MA', 10000);insert into College values ('Cornell', 'NY', 21000);insert into Apply values (123, 'Stanford', 'CS', 'Y');insert into Apply values (123, 'Stanford', 'EE', 'N');insert into Apply values (123, 'Berkeley', 'CS', 'Y');insert into Apply values (123, 'Cornell', 'EE', 'Y');insert into Apply values (234, 'Berkeley', 'biology', 'N');insert into Apply values (345, 'MIT', 'bioengineering', 'Y');insert into Apply values (345, 'Cornell', 'bioengineering', 'N');insert into Apply values (345, 'Cornell', 'CS', 'Y');insert into Apply values (345, 'Cornell', 'EE', 'N');insert into Apply values (678, 'Stanford', 'history', 'Y');insert into Apply values (987, 'Stanford', 'CS', 'Y');insert into Apply values (987, 'Berkeley', 'CS', 'Y');insert into Apply values (876, 'Stanford', 'CS', 'N');insert into Apply values (876, 'MIT', 'biology', 'Y');insert into Apply values (876, 'MIT', 'marine biology', 'N');insert into Apply values (765, 'Stanford', 'history', 'Y');insert into Apply values (765, 'Cornell', 'history', 'N');insert into Apply values (765, 'Cornell', 'psychology', 'Y');insert into Apply values (543, 'MIT', 'CS', 'N');
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started