Fetch records of postgres and store it in different table , if one column is null
Well, normally id is used to implement primary key which is not nullable... But I guess your problem is that you're getting dirty data from another source and try to sort it out ?

You could either design correctly (with all due constraints) your table and use a tool like pg_loader to load your data. It will create a error file with all the lines that don't fit.

Or you can import all your data into a junk table (which is the approach you seem to have chosen) and perform SQL on top of that to sort out your data.

You can try something like that:

/*Processing "nulls" that can be a problem*/
with nullable_rows as
(
  delete
  from input_table
  where id is null
    or  emp is null
    /*Add any other condition here*/
  returning *
)
insert into null_table
(id, emp, salary, year)
select * from nullable_rows;

/*Processing correct rows*/
with correct_rows as
(
  delete
  from input_table
  where id is not null
    and emp is not null
    /*Add any other condition here*/
  returning *
)
insert into sucess_table
(id, emp, salary, year)
select * from correct_rows;


That's if you load your data out of another source.

If another source is inserting dirty data in your database, use constraints to prevent it...