SELECT  
        `period_liquidations`.`apply_to` AS `apply_to`,
        `period_liquidations`.`status` AS `Status`,
        `period_liquidations`.`period_id` AS `IdPeriodo`,
        `period_liquidations`.`person_id` AS `IdEmpresa`,
        `b`.`document` AS `DocumentoEmpresa`,
        `b`.`field_name1` AS `NombreEmpresa`,
        `p`.`date_from` AS `Desde`,
        `p`.`date_to` AS `Hasta`,
        `p`.`code` AS `Periodo`
        


    FROM `period_liquidations`
        LEFT JOIN `persons` `b` ON `period_liquidations`.`person_id` = `b`.`id`
        LEFT JOIN `periods` `p` ON `period_liquidations`.`period_id` = `p`.`id`
        
    order by Periodo,NombreEmpresa