COMPUTER SCIENCE AND ENGINEERING
SQL
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
Which SQL query would display all pupils who are older than 12?
|
SELECT * FROM Pupils WHERE age > 12
|
|
SELECT * FROM Pupils WHERE age < 12
|
|
SELECT * FROM Pupils WHERE age > “12”
|
|
SELECT * FROM Pupils WHERE age >= 12
|
Explanation:
Detailed explanation-1: -We can find the age of a person from their date of birth by using this formula: SELECT DATE FORMAT(FROM DAYS(DATEDIFF(NOW(), ’DATE OF BIRTH’)), ‘%Y’) + 0 AS age; In the above formula, we are first finding the difference between the current date (NOW()) and the date of birth (in YYYY-MM-DD) using the DATEDIFF() function.
There is 1 question to complete.