Select from where group by having q35 find average

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: s. SELECT FROM WHERE GROUP BY HAVING (Q35) Find average age of sailors who are of voting age for each rating rating level that has at least 2 sailors. S.rating, MIN(S.age) as minage S.rating, MIN(S.age) Sailors S S.age >= 18 S.rating COUNT(*) > 1; SELECT FROM WHERE GROUP BY HAVING S.rating, AVG(S.age) as avgage S.rating, AVG(S.age) Sailors S S.age >= 18 S.rating 1 < (SELECT COUNT(*) FROM Sailors S2 WHERE S.rating = S2.rating; 49 49 50 Insert Tuples Insert Tuples Suppose we have created a table for the relation: Students (sid, name, login, age, gpa) gpa) (sid Can insert tuples from one table into another. E.g., create a table for the relation SmartStudents (sid, name, login, age). Then insert tuples from Students into SmartStudents: SmartStudents: To insert a new tuple: tuple: INSERT INTO Students (sid, name, login, age, gpa) sid, gpa) VALUES (53688, ‘Smith’,’smith@ee’, 18, 3.2); Smith’ smith@ee’ INSERT INTO SmartStudents (sid, name, login, age) sid, SELECT sid, name, login, age sid, FROM...
View Full Document

This note was uploaded on 10/15/2012 for the course CSE 4503 taught by Professor Edallen during the Fall '12 term at Mississippi State.

Ask a homework question - tutors are online