Skip to content
Advertisement

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

I have a table like this

when I write a select statement

I got an empty result set.

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

Advertisement

Answer

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):

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

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement