Skip to content
Advertisement

How to fill missing dates by ID in a table in sql

I have table A which has Dates and EMPID eg below

I also have Table B which has a date range

My table A has missing dates and EMPID.

How can I merge the two tables to have the following table.

Thanks in advance. This is being used in a dataset(SQL) in SSRS. P.S. I’m new to coding in SQL environment, My background is in ABAP

Advertisement

Answer

You can cross join the distinct empid coming from a with dates coming from b, as follows:

Or if you are looking to insert “missing” dates in a, then you can use the insert ... select syntax with a not exists condition:

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