SELECT a.id, a.archive_id, a.bk_name, b.ip
FROM archive a, backup b
WHERE a.file_status = 0 and a.bkup_name = b.bkup_name and a.backup_date < 'now'::datetime -
'(SELECT s.maxday_savefile FROM backupservice s
WHERE info.service_type = s.service and a.backup_id = info.backup_id) days'::timespan;