1
I’m doing an SQL where I need to show the purchase orders. However a purchase order, can have several quotations and do not want to keep repeating the quotations, I want to bring me the quotation only once without repeating.
[![select c.Empresa, p.Nome,
c.data,c.NumeroOC, c.fornecedor, pe.nome,
(Convert(Numeric(10,2), c.valor)) as 'Valor',
det.descricao as 'Local de Entrega',l.Descricao as 'CR',
Case when c.situacao = 1 then
'Pendente'
when c.situacao = 2 then
'Atendida Parcialmente'
when c.situacao = 3 then
'Atendida Totalmente'
when c.situacao = 4 then
'Finalizada Manualmente' end as 'Status',
c.ordemaut,
ic.Cotacao,
c.Obs
from compras c
inner join pessoas p on (c.empresa = p.codigo)
inner join pessoas pe on (c.fornecedor = pe.codigo)
inner join locais l on (c.cresultado = l.codigo) and tipolocal = 'CR'
inner join detpessoas det on (det.Sequencial = c.LocalEntrega)
inner join itenscompra ic on (c.SequencialOC = ic.SequencialOC)][1]][1]
And which of the existing quotes would you like to see displayed? I believe that the GROUP BY clause and an aggregation function (MAX for example) can help you.
– anonimo
I just don’t want to see it repeated. If a PURCHASE ORDER has had 2 quotes, I want to see the Dudas, but I don’t want to see them repeated.
– Julio Cesar Andrade
Define better what you mean by "repetitions" since, from what I understand, you want to see such repetitions.
– anonimo
I posted a photo too. The oc number and the quotations are the same and I want to group them. I even tried to make a group by, but the bank asks me to group field by field, which is unfeasible in the query.
– Julio Cesar Andrade
Attached images are not welcome on this site. See: Manual on how NOT to ask questions
– anonimo