Generation

text to sql syntaxFri, 12 May 2023

select cast(tnh.dataemissao as date) as data ,tnh.codloja as codigo_loja ,sum(tnh.valortotal) as VALOR_VENDA ,count(1) as clientes ,case when (select count(1) from tab_controle_nfe tcn where cod_situacao_envio_nfe ='IN' and cod_unidade=tnh.codloja and cast(dth_recbto as date)=cast(tnh.dataemissao as date))=1 then 'SIM' else 'NAO' end as pendencia_sefaz from tab_nota_header tnh where tnh.dataemissao between '2023-05-11 00:00:00' and '2023-05-11 23:59:59' and tnh.codloja =2 group by cast(tnh.dataemissao as date),tnh.codloja,case when (select count(1) from tab_controle_nfe tcn where cod_situacao_envio_nfe ='IN' and cod_unidade=tnh.codloja and cast(dth_recbto as date)=cast(tnh.dataemissao as date))=1 then 'SIM' else 'NAO' end;

Questions about programming?Chat with your personal AI assistant