Ir ao conteúdo
  • Cadastre-se

rcamu

Membro Júnior
  • Posts

    1
  • Cadastrado em

  • Última visita

Reputação

0
  1. Fiz o Select abaixo só que ele não está somando pela coluna correta, onde estou errando? Na minha estrutura tenho o campo dtConcat e o campo dtConcat2 (essas datas são diferentes uma é para data do pedido e a outra é para a data que efetivou a venda) ele está somando a coluna dtConcat2 mesmo eu colocando no select que quero o mes e ano da coluna dtConcat SELECT cat.id, cat.nome_vendedor, MONTH (dtConcat) AS mes, YEAR (dtConcat) AS ano, SUM( IF( mov.tipo_venda = 'Atacado', mov.total, 0 ) ) AS Atacado FROM lc_controle AS mov INNER JOIN vendedor AS cat ON cat.id = mov.vendedor where mov.exportado = 'Sim' GROUP BY ano, mes, cat.nome_vendedor ORDER BY nome_vendedor, ano, mes Segue a estrutura das tabelas. lc_controle CREATE TABLE `lc_controle` ( `id` int(11) NOT NULL, `dtConcat` date NOT NULL, `dtConcat2` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `clienteVa` varchar(100) NOT NULL, `fornec` varchar(100) DEFAULT NULL, `clienteAt` varchar(100) NOT NULL, `userml` varchar(50) DEFAULT NULL, `rastreador` text, `entrega` text, `total` decimal(20,2) DEFAULT NULL, `frete` decimal(20,2) DEFAULT NULL, `frete_real` decimal(20,2) DEFAULT NULL, `nf` varchar(50) DEFAULT NULL, `origem` varchar(50) DEFAULT NULL, `tipo_pagto` text, `descricao` text, `tipo` int(11) DEFAULT NULL, `tipo_venda` text, `vendedor` int(11) DEFAULT NULL, `exportado` varchar(11) DEFAULT NULL, `pago` varchar(11) NOT NULL, `incluido_por` varchar(25) NOT NULL, `date_incluido` datetime NOT NULL, `alterado_por` varchar(25) NOT NULL, `date_alterado` datetime NOT NULL, `exportado_por` varchar(25) NOT NULL, `date_exportado` datetime NOT NULL, `st` decimal(20,2) NOT NULL, `total_st` decimal(20,2) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; vendedor CREATE TABLE `vendedor` ( `id` int(11) NOT NULL, `data2` date NOT NULL, `nome_vendedor` text NOT NULL, `descricao` text NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8;

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...