Which of the following query will correctly retrieve the names in uppercase of all those who joined in year 2022 , from emp table ?
Note: Consider 'name' as the column containing names of the employees and 'doj' is the field containing date of joining of employees.
Which of the following query will correctly retrieve the names in uppercase of all those who joined in year 2022 , from emp table ?
Note: Consider 'name' as the column containing names of the employees and 'doj' is the field containing date of joining of employees.
Solution
UPPER(name) converts each name to uppercase, and WHERE YEAR(doj)=2022 keeps only rows whose joining year is 2022. The clause order is also correct: SELECT, FROM, then WHERE.
Option 2: MONTHNAME(doj) returns a month name such as 'March', so it can never equal '2022'.
Option 3: the WHERE clause is placed before FROM, which is a syntax error.
Option 4: GROUP BY groups rows and does not filter them. Use WHERE for row conditions.
Related questions:
2025: 15 May Shift 2
2025: 22 May Shift 1
2025: 15 May Shift 2