Skip to content

Instantly share code, notes, and snippets.

@viniciusss
Created June 26, 2013 17:22
Show Gist options
  • Save viniciusss/5869407 to your computer and use it in GitHub Desktop.
Save viniciusss/5869407 to your computer and use it in GitHub Desktop.
SELECT distinct(c.id_carga)
FROM webpdv.cargas c
left join webpdv.cargas_entregas_vinculadas cev using(id_carga)
LEFT JOIN webpdv.pedidos_entregas USING(id_pedido_entrega)
LEFT JOIN webpdv.lojas_central_entrega USING(id_loja_central_entrega)
WHERE LEFT(data_hora_criacao, 10) >= '2013-06-24'
AND cev.bln_etiqueta = 1
AND id_pedido_entrega_tipo IN(1, 5)
AND id_status_entrega NOT IN(3, 5)
and exists(
select 'x'
from webpdv.pedidos_entregas_agendamento pea
where pea.id_pedido_entrega = cev.id_pedido_entrega
and pea.id_usuario = 8651
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment