Skip to content

Instantly share code, notes, and snippets.

@rfunix
Created May 23, 2017 13:55
Show Gist options
  • Select an option

  • Save rfunix/8c55a485e2d6247f1e177b2259ea2462 to your computer and use it in GitHub Desktop.

Select an option

Save rfunix/8c55a485e2d6247f1e177b2259ea2462 to your computer and use it in GitHub Desktop.
QUERY LOCA
/****** Script do comando SelectTopNRows de SSMS ******/
SELECT VendasCorp.Diaria as Timestamp,
VendasCorp.Descr_Regional as Regional,
VendasCorp.Apelido_Pessoa as ApelidoLoja,
VendasCorp.Nome_Pessoa as RazaoLoja,
VendasCorp.Cobol_Cod_Loja as CodigoLoja,
VendasCorp.Acumulado as DataAcumuladoAtualInicio,
VendasCorp.Data_Acu_Fim as DataAcumuladoAtualFim,
VendasCorp.Dia_Acum as AcumuladoAtual,
VendasCorp.Acumulado_Ant as DataAcumuladoAnteriorInicio,
VendasCorp.Data_Acu_Fim as DataAcumuladoAnteriorFinal,
VendasCorp.Ant_Acum as AcumuladoAnterior,
Peças,
Tickets
FROM [Corp].[dbo].[vw_Relatorio] VendasCorp
INNER JOIN (
SELECT COUNT(*) as Peças, codigoLoja from [ERP].[pdv].[fn_VendaERP_Por_Produto_Cor_Tamanho]
(
'20170522',
'20170522'
)
group by codigoLoja
) Itens
on Itens.codigoLoja = VendasCorp.Cobol_Cod_Loja
INNER JOIN (
SELECT COUNT(DISTINCT comanda) as Tickets, codigoLoja from [ERP].[pdv].[fn_VendaERP_Por_Produto_Cor_Tamanho]
(
'20170522',
'20170522'
)
group by codigoLoja
) Comandas
on Comandas.codigoLoja = VendasCorp.Cobol_Cod_Loja
where VendasCorp.Diaria = '20170522'
and VendasCorp.Se_Funcionando = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment