You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SELECT "Pedido".*,
(SELECT CASE
WHEN GREATEST(CANCELADOS."createdAt",
CONFIRMADOS."createdAt",
DEMORADOS."createdAt",
ENTREGADOS."createdAt",
FABRICANDOS."createdAt",
FACTURADOS."createdAt",
FINALIZADOS."createdAt",
PRESUPUESTADOS."createdAt") = CANCELADOS."createdAt" THEN 'Cancelado'
WHEN GREATEST(CANCELADOS."createdAt",
CONFIRMADOS."createdAt",
DEMORADOS."createdAt",
ENTREGADOS."createdAt",
FABRICANDOS."createdAt",
FACTURADOS."createdAt",
FINALIZADOS."createdAt",
PRESUPUESTADOS."createdAt") = CONFIRMADOS."createdAt" THEN 'Confirmado'
WHEN GREATEST(CANCELADOS."createdAt",
CONFIRMADOS."createdAt",
DEMORADOS."createdAt",
ENTREGADOS."createdAt",
FABRICANDOS."createdAt",
FACTURADOS."createdAt",
FINALIZADOS."createdAt",
PRESUPUESTADOS."createdAt") = DEMORADOS."createdAt" THEN 'Demorado'
WHEN GREATEST(CANCELADOS."createdAt",
CONFIRMADOS."createdAt",
DEMORADOS."createdAt",
ENTREGADOS."createdAt",
FABRICANDOS."createdAt",
FACTURADOS."createdAt",
FINALIZADOS."createdAt",
PRESUPUESTADOS."createdAt") = ENTREGADOS."createdAt" THEN 'Entregado'
WHEN GREATEST(CANCELADOS."createdAt",
CONFIRMADOS."createdAt",
DEMORADOS."createdAt",
ENTREGADOS."createdAt",
FABRICANDOS."createdAt",
FACTURADOS."createdAt",
FINALIZADOS."createdAt",
PRESUPUESTADOS."createdAt") = FABRICANDOS."createdAt" THEN 'Fabricando'
WHEN GREATEST(CANCELADOS."createdAt",
CONFIRMADOS."createdAt",
DEMORADOS."createdAt",
ENTREGADOS."createdAt",
FABRICANDOS."createdAt",
FACTURADOS."createdAt",
FINALIZADOS."createdAt",
PRESUPUESTADOS."createdAt") = FACTURADOS."createdAt" THEN 'Facturado'
WHEN GREATEST(CANCELADOS."createdAt",
CONFIRMADOS."createdAt",
DEMORADOS."createdAt",
ENTREGADOS."createdAt",
FABRICANDOS."createdAt",
FACTURADOS."createdAt",
FINALIZADOS."createdAt",
PRESUPUESTADOS."createdAt") = FINALIZADOS."createdAt" THEN 'Finalizado'
WHEN GREATEST(CANCELADOS."createdAt",
CONFIRMADOS."createdAt",
DEMORADOS."createdAt",
ENTREGADOS."createdAt",
FABRICANDOS."createdAt",
FACTURADOS."createdAt",
FINALIZADOS."createdAt",
PRESUPUESTADOS."createdAt") = PRESUPUESTADOS."createdAt" THEN 'Presupuestado'
END ultimo_estado
FROM "Pedidos"
LEFT JOIN "Cancelados" AS CANCELADOS ON CANCELADOS."PedidoId" = "Pedidos"."id"
LEFT JOIN "Confirmados" AS CONFIRMADOS ON CONFIRMADOS."PedidoId" = "Pedidos"."id"
LEFT JOIN "Demorados" AS DEMORADOS ON DEMORADOS."PedidoId" = "Pedidos"."id"
LEFT JOIN "Entregados" AS ENTREGADOS ON ENTREGADOS."PedidoId" = "Pedidos"."id"
LEFT JOIN "Fabricandos" AS FABRICANDOS ON FABRICANDOS."PedidoId" = "Pedidos"."id"
LEFT JOIN "Facturados" AS FACTURADOS ON FACTURADOS."PedidoId" = "Pedidos"."id"
LEFT JOIN "Finalizados" AS FINALIZADOS ON FINALIZADOS."PedidoId" = "Pedidos"."id"
LEFT JOIN "Presupuestados" AS PRESUPUESTADOS ON PRESUPUESTADOS."PedidoId" = "Pedidos"."id"
where "Pedido"."id" = "Pedidos"."id" ) as ultimo_estado,
"Persona"."id" AS "Persona.id",
"Persona"."identificacion" AS "Persona.identificacion",
"Persona"."nombre" AS "Persona.nombre",
"Persona"."apellido" AS "Persona.apellido",
"Persona"."direccion" AS "Persona.direccion",
"Persona"."localidad" AS "Persona.localidad",
"Persona"."email" AS "Persona.email",
"Persona"."fecha_nacimiento" AS "Persona.fecha_nacimiento",
"Persona"."telefono" AS "Persona.telefono",
"Persona"."createdAt" AS "Persona.createdAt",
"Persona"."updatedAt" AS "Persona.updatedAt",
"Persona"."deletedAt" AS "Persona.deletedAt",
"Detalles"."id" AS "Detalles.id",
"Detalles"."renglon" AS "Detalles.renglon",
"Detalles"."cantidad" AS "Detalles.cantidad",
"Detalles"."PedidoId" AS "Detalles.PedidoId",
"Detalles"."HuesoId" AS "Detalles.HuesoId",
"Detalles"."createdAt" AS "Detalles.createdAt",
"Detalles"."updatedAt" AS "Detalles.updatedAt",
"Detalles"."deletedAt" AS "Detalles.deletedAt",
"Detalles->Hueso"."id" AS "Detalles.Hueso.id",
"Detalles->Hueso"."nombre" AS "Detalles.Hueso.nombre",
"Detalles->Hueso"."numero" AS "Detalles.Hueso.numero",
"Detalles->Hueso"."subtipohueso" AS "Detalles.Hueso.subtipohueso",
"Detalles->Hueso"."tipohueso" AS "Detalles.Hueso.tipohueso",
"Detalles->Hueso"."disponible" AS "Detalles.Hueso.disponible",
"Detalles->Hueso"."DinosaurioId" AS "Detalles.Hueso.DinosaurioId",
"Detalles->Hueso"."createdAt" AS "Detalles.Hueso.createdAt",
"Detalles->Hueso"."updatedAt" AS "Detalles.Hueso.updatedAt",
"Detalles->Hueso"."deletedAt" AS "Detalles.Hueso.deletedAt",
"Detalles->Hueso->Dinosaurio"."id" AS "Detalles.Hueso.Dinosaurio.id",
"Detalles->Hueso->Dinosaurio"."nombre" AS "Detalles.Hueso.Dinosaurio.nombre",
"Detalles->Hueso->Dinosaurio"."alimentacion" AS "Detalles.Hueso.Dinosaurio.alimentacion",
"Detalles->Hueso->Dinosaurio"."periodo" AS "Detalles.Hueso.Dinosaurio.periodo",
"Detalles->Hueso->Dinosaurio"."descubrimiento" AS "Detalles.Hueso.Dinosaurio.descubrimiento",
"Detalles->Hueso->Dinosaurio"."SubClaseId" AS "Detalles.Hueso.Dinosaurio.SubClaseId",
"Detalles->Hueso->Dinosaurio"."createdAt" AS "Detalles.Hueso.Dinosaurio.createdAt",
"Detalles->Hueso->Dinosaurio"."updatedAt" AS "Detalles.Hueso.Dinosaurio.updatedAt",
"Detalles->Hueso->Dinosaurio"."deletedAt" AS "Detalles.Hueso.Dinosaurio.deletedAt"
FROM
(SELECT "Pedido"."id",
"Pedido"."autorizacion",
"Pedido"."motivo",
"Pedido"."tipo",
"Pedido"."PersonaId",
"Pedido"."createdAt",
"Pedido"."updatedAt",
"Pedido"."deletedAt"
FROM "Pedidos" AS "Pedido"
LIMIT '200'
OFFSET '0') AS "Pedido"
LEFT OUTER JOIN "Personas" AS "Persona" ON "Pedido"."PersonaId" = "Persona"."id"
AND ("Persona"."deletedAt" IS NULL)
LEFT OUTER JOIN "Detalles" AS "Detalles" ON "Pedido"."id" = "Detalles"."PedidoId"
AND ("Detalles"."deletedAt" IS NULL)
LEFT OUTER JOIN "Huesos" AS "Detalles->Hueso" ON "Detalles"."HuesoId" = "Detalles->Hueso"."id"
AND ("Detalles->Hueso"."deletedAt" IS NULL)
LEFT OUTER JOIN "Dinosaurios" AS "Detalles->Hueso->Dinosaurio" ON "Detalles->Hueso"."DinosaurioId" = "Detalles->Hueso->Dinosaurio"."id"
AND ("Detalles->Hueso->Dinosaurio"."deletedAt" IS NULL)WHERE ("Pedido"."deletedAt" IS NULL
AND ("Pedido"."id"::text ILIKE '%Anky%'
OR "Detalles->Hueso->Dinosaurio"."nombre" ILIKE '%Anky%'));
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: