Basic SQL questions
Write the following queries in SQL, using the university schema
Please, Take the sample data from attached link for university schema. Using the university schema, write the following queries.
select title from course where dept_name = 'Comp. Sci.' and credits=3;
select course_id, title from course as c left outer join
student as s on c.dept_name = s.dept_name where s.id = '24746';
Natural join: A natural join in SQL combines rows from two or more tables based on the common column(s) between them.
select distinct(name) from student where
student.id = (select id from student natural join takes where dept_name = 'Comp. Sci.');
select t.course_id, c.title from takes as t left outer join course as c on t.course_id = c.course_id where id = '24746';
or
select course_id, title from takes natural join course where ID='24746';
select sum(credits) from takes natural join course where id='24746';
select id,sum(credits) from takes natural join course group by id;
select name,id from instructor where id not in (select id from teaches);
Reference : https://db-book.com/