Exibe os pedidos com faturamento em atraso.

Descrição: PEDIDOS FATURAMENTO ATRASADO

Comando SQL:
SELECT COUNT(*) AS CONTA,
       GROUP_CONCAT(
           CONCAT(LPAD(PEDBASE.NUMERO,8,'0'),' ',FORMATA(LPAD(PEDBASE.CLIENTE,7,'0'),'######-#'),' ',TABC.NOME,'\r\n',
              'Data ped: ',DATE_FORMAT(PEDBASE.DATAPEDIDO,'%d/%m/%Y'),' Prev fat: ',DATE_FORMAT(PEDBASE.DATAPREVFAT,'%d/%m/%Y'),'\r\n',
              LPAD(FORMATA_VALOR(PEDBASE.TOTNF,2),12,' '),' ',PEDBASE.OPERACAO,' ',TABOPER.DESCRICAO,'\r\n')
           ORDER BY PEDBASE.DATAPREVFAT, PEDBASE.NUMERO
           SEPARATOR '\r\n'
           ) AS DESCRICAO,
	     GROUP_CONCAT(
	       CONCAT('PED:',PEDBASE.ESTAB,'-',PEDBASE.NUMERO,';Pedido: ',LPAD(PEDBASE.NUMERO,8,'0'))
	       ORDER BY PEDBASE.DTAREARESP 
	       SEPARATOR '^') AS LINK
FROM PEDBASE
LEFT OUTER JOIN TABCLI TABC ON TABC.CODIGO = PEDBASE.CLIENTE
LEFT OUTER JOIN TABOPER ON TABOPER.CODIGO = PEDBASE.OPERACAO
WHERE PEDBASE.TIPO = 'P'
AND PEDBASE.SITUACAO IN ('E','P')
AND PEDBASE.DATAPREVFAT < CURDATE()