MySQL Exercise 3: SELECT SQL Statement in Khmer
In this tutorial I show you another important 5 SQL Select Questions with mix different tables and aggregate function like COUNT, SUM, MIN, MAX, AVG with some condition.លំហាត់ MySQL SQL SELECT Exercise: #1 | #2 | #3
Below is the questions in Khmer - helping you to understand more.
This is the EER Diagram (Table Relationship) to help you to understand more.
Learn More Introduction to Database (SQL) in Khmer with videos: Chapter 1 | Chapter 2 | Chapter 3
#1) Show student name and number of book that student had borrow in 2017
SELECT b.name, count(o.bookID) as Counts
FROM books b INNER JOIN borrows o
ON b.bookID = o.bookID
WHERE year(takenDate)=2017
GROUP BY b.name;
#2 Show student information with age greater than 18
SELECT * FROM students
WHERE year(curdate() - birthdate) > 18;
Note: We have two function here: ◾Year(): get the year from the input value
◾curdate(): return the current date
#3 show name, gender and age of all students
SELECT name, gender, year(curdate())-year(birthdate) as Age
FROM students;
#4 show average point of students in class 11A
SELECT AVG(point) FROM students
WHERE class='11a';
#5 show total point, average, maximum and minimum point of all student in class 11A
SELECT sum(point), avg(point), max(point), min(point)
FROM students
WHERE class='11a';
EP12 សំនួរចម្លើយ SQL SELECT Statement លំហាត់ទី៣ Library Database