Soru
Q1-Asswer the following questions by writing an SOL statement using the tables below. (21 points) , frame, dob, dop,addren, city) book (isny, title, no of pages, publisher writer) reservationirsectration M, date out, date a) Display finst name lant name and address of all guests whose city is same as Alex Ball (7 points) SELECT fname , Iname , address FR OM guest WHERE city='Alex Bald' b) Display the guests fname, Iname and the name of the book they took out. (7 points) c) Display the number of books each guest tock out in lotal (7 points)
Çözüm
4.1300 Voting
Yaşar
Profesyonel · 6 yıl öğretmeniUzman doğrulaması
Cevap
a) Display first name, last name, and address of all guests whose city is same as Alex Ball.<br />```sql<br />SELECT fname, lname, address<br />FROM guest<br />WHERE city = 'Alex Ball';<br />```<br /><br />b) Display the guests' first name, last name, and the name of the book they took out.<br />```sql<br />SELECT g.fname, g.lname, b.title<br />FROM guest g<br />JOIN book b ON g.addren = b.writer;<br />```<br /><br />c) Display the number of books each guest took out in total.<br />```sql<br />SELECT g.fname, g.lname, SUM(b.no_of_pages) as total_pages<br />FROM guest g<br />JOIN book b ON g.addren = b.writer<br />GROUP BY g.fname, g.lname;<br />```
Derecelendirmek için tıklayın: