Good afternoon, everyone!
I have a sql query that is simple but I'm having a hard time performing an order by two fields at the same time. Such a query is for me to assemble a report, but before assembling I need to validate this query. The query that is being performed is this:
select
cped.razsocial,
cped.nrpedido,
iped.codbarra,
iped.codprod,
iped.qtde,
iped.descricao,
funcionario.fantasia,
cped.dtpedido,
produto.observacao,
cped.liberado,
cped.statusweb
from cped
inner join iped on (cped.nrpedido = iped.nrpedido)
inner join produto on (iped.codprod = produto.codprod)
inner join funcionario on (cped.indicacao = funcionario.funcionario)
inner join almox on (cped.almoxarifado = almox.codigo )
where (
(cped.tipo = 'Z') )
group by
cped.razsocial,
cped.nrpedido,
iped.codbarra,
iped.codprod,
iped.qtde,
iped.descricao,
funcionario.fantasia,
cped.dtpedido,
produto.observacao,
cped.liberado,
cped.statusweb
order by iped.descricao,cped.nrpedido
When executing the command it works fine, however it only orders by iped.description. I need it to order by description but the field must be attached, ie if the customer has 3 items within the order with descriptions of different items, he does not throw the order at the end of the list but leave it grouped. / p>
Thank you in advance.