Skip to main contentSkip to solution

Consider a table 'EMPLOYEE':

EMPIDEmpNameDOBDOJSalary
E001Sumit1994-10-102020-05-0550000
E002Ajay1995-08-112021-07-0860000
E003Amit1993-04-142012-04-0970000

If we have to select DAY, MONTH and YEAR of birth of all EMPLOYEE, which of the following query should be used?

Solution

✅ Correct Option: 2

Option 2 lists the three functions DAY(DOB)DAY(DOB), MONTH(DOB)MONTH(DOB) and YEAR(DOB)YEAR(DOB) separated by commas. This returns the day, month and year as three separate columns for every employee, which is what the question asks for.


Option 1: in MySQL, || is the logical OR operator by default, so it does not join the values into one string and does not give three separate columns.

Option 3: SELECT * returns every column, including the full date, not the separate day, month and year.

Option 4: && is the logical AND operator, so it gives a single 0 or 1 result, not the date parts.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question