SELECT
    dist_id,
    target_id,
    distRun.stage,
    stage_id,
    CONCAT_WS('.', distRun.outroot, CONVERT(distRun.dist_id, CHAR)) as dist_dir,
    rcDSProduct.name AS product_name,
    rcDSProduct.prod_id,
    rcDSProduct.dbname AS ds_dbname,
    rcDSProduct.dbhost AS ds_dbhost
FROM rcDestination 
JOIN rcInterest USING(dest_id) 
JOIN distTarget USING(target_id) 
JOIN rcDSProduct USING(prod_id)
JOIN distRun USING(target_id) 
LEFT JOIN rcDSFileset USING(prod_id, dist_id)
WHERE distRun.state = 'full'
    AND rcDSFileset.fs_id IS NULL
