Skip to content

Is there a function in sql server “isEmpty” return data if the select return empty result set

I have a table like this

EmpId  No_of_days
  1       24
  2       28
  6       24
  7       30
  8       10
  9       15

when I write a select statement

SELECT No_of_days FROM _table WHERE EmpId = 3 or 4 or 5

I got an empty result set.

I want the result set return 0 days for employees 3 and 4 and 5



Assuming that you have another table with all your employees in (if not, where are employees 3, 4 and 5 coming from?), you could use a LEFT JOIN onto your example table (_table):

SELECT e.empid,
FROM Employee e --No idea what your employee table is actually called, so guessed.
     LEFT JOIN _table t ON e.empid = t.empid;

This will provide rows for all your employees. If you wanted just 3, 4 and 5, then you would add your WHERE:

 WHERE e.empid IN (3,4,5)
2 People found this is helpful