Ir para conteúdo
Fórum Script Brasil

Vitor Ruiz

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Sobre Vitor Ruiz

Vitor Ruiz's Achievements

0

Reputação

  1. Olá, criei a Query abaixo porém está me retornando o seguinte erro : "Falha ao converter o varchar valor 'ÚLTIMA COMPRA' para o tipo de dados int." como posso realizar essa conversão deste trecho? case when datediff(day,cab.dtneg,getdate())/30 > 12 then 'ÚLTIMA COMPRA' else datediff(day,cab.dtneg,getdate())/30 end as 'MESES DA ÚLTIMA COMPRA' select distinct cab.numnota as NOTA, par.codparc as 'CÓD PARC', par.nomeparc as PARCEIRO, convert(varchar,cab.dtneg,103) as 'DATA', ven.apelido as VENDEDOR, tpo.descroper as 'TOP', convert(varchar,getdate(),103) as 'DATA DA EMISSÃO DO RELATÓRIO', cab.vlrnota as VALOR, case when datediff(day,cab.dtneg,getdate())/30 > 12 then 'ÚLTIMA COMPRA' else datediff(day,cab.dtneg,getdate())/30 end as 'MESES DA ÚLTIMA COMPRA' from TGFPAR PAR, TGFCAB CAB, TGFTOP TPO, TGFVEN VEN where par.codparc = cab.codparc and tpo.codtipoper = cab.codtipoper and ven.codvend = par.codvend and datediff(day,getdate(),cab.dtneg)*-1 >= 60 and (cab.codtipoper = '3200' or cab.codtipoper = '36' or cab.codtipoper = '130' or cab.codtipoper = '233' or cab.codtipoper = '220' or cab.codtipoper = '218') and cab.dtneg = (select max (cab2.dtneg) from TGFCAB CAB2 where par.codparc = cab2.codparc) order by 'Vendedor' asc
×
×
  • Criar Novo...