Sailors select countdistinct ssname ssname from

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’ names. sailors’ SELECT COUNT(DISTINCT S.sname) S.sname) FROM Sailors S; S.sname, S.age S.sname, Sailors S S.age = (SELECT MAX(S2.age) FROM Sailors S2); 45 Query Examples (continued) Query Examples (continued) (Q30) Find names of sailors who are older than oldest sailor with rating of rating 10. (Q31) Find age of youngest sailor for each rating level. SELECT S.rating, MIN(S.age) S.rating, MIN(S.age) FROM Sailors S GROUP BY S.rating; S.rating; Solution using MAX: SELECT FROM WHERE S.sname Sailors S S.age > To rename ouput column with minimum age: (SELECT MAX(S2.age) FROM Sailors S2 WHERE S2.rating = 10); SELECT S.rating, MIN(S.age) as minage S.rating, MIN(S.age) FROM Sailors S GROUP BY S.rating; S.rating; Solution using ALL: SELECT FROM WHERE 46 S.sname Sailors S S.age > ALL (SELECT S2.age FROM Sailors S2 WHERE S2.rating = 10); 47 48 Query Examples (continued) Query Examples (continued) (Q32) Find age of youngest sailor who is eligible to vote (i.e., is at least 18 years old) for each rating level with at least 2 such sailor...
View Full Document

Ask a homework question - tutors are online