Multiple choice

Consider the following table.

empid empname joiningdate
1 John 2013-08-10
2 Micky 2012-08-10

Write a query to retrieve all th employee names, who have worked for more than 200 days.

  1. select empname from emp where datediff(curdate(),joiningdate)>20;

  2. select empname from emp where datediff(curdate(),joiningdate)>200;

  3. select empname from emp where datediff(joiningdate,curdate())>200;

  4. select from emp where datediff(curdate(),joiningdate)>200;

  5. none of these

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

datediff produces the difference of its two arguments in days. Hence currentdate, when subtracted with the joining date gives the number of days.