Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query para teaer todos los guias que hablan un idiom dado ( tambien trea los demas idiomas que habla el guia ) #69

Open
CarlosIrigoyen opened this issue May 7, 2024 · 0 comments

Comments

@CarlosIrigoyen
Copy link
Contributor

CarlosIrigoyen commented May 7, 2024

SELECT "Persona".*,
      "Guia"."id" AS "Guia.id",
      "Guia"."dias_trabaja" AS "Guia.dias_trabaja",
      "Guia"."horario_trabaja" AS "Guia.horario_trabaja",
      "Guia"."PersonaId" AS "Guia.PersonaId",
      "Guia"."createdAt" AS "Guia.createdAt",
      "Guia"."updatedAt" AS "Guia.updatedAt",
      "Guia"."deletedAt" AS "Guia.deletedAt",
      STRING_AGG("Idiomas"."nombre",',') AS "Idiomas"
      FROM (
      SELECT "Persona"."id",
      "Persona"."identificacion",
      "Persona"."nombre",
      "Persona"."apellido"
      --"Persona"."direccion",
      --"Persona"."localidad",
      --"Persona"."email",
      --"Persona"."fecha_nacimiento",
      --"Persona"."telefono",
      --"Persona"."createdAt",
      --"Persona"."updatedAt",
      --"Persona"."deletedAt"
      FROM "Personas" AS "Persona"
      WHERE "Persona"."deletedAt" IS NULL
      ORDER BY "id" ASC
      LIMIT 10
      OFFSET 0
      ) AS "Persona"
      LEFT OUTER JOIN "Guia" AS "Guia" ON "Persona"."id" = "Guia"."PersonaId"
      AND "Guia"."deletedAt" IS NULL
      LEFT OUTER JOIN "IdiomaGuia" AS "GuiaIdioma" ON "Guia"."id" = "GuiaIdioma"."GuiumId"
      LEFT OUTER JOIN "Idiomas" AS "Idiomas" ON "GuiaIdioma"."IdiomaId" = "Idiomas"."id"
      WHERE EXISTS (
      SELECT 1
      FROM "IdiomaGuia" AS "GuiaIdioma"
      JOIN "Idiomas" AS "Idiomas" ON "GuiaIdioma"."IdiomaId" = "Idiomas"."id"
      WHERE "GuiaIdioma"."GuiumId" = "Guia"."id"
      AND "Idiomas"."nombre" ILIKE '%inglés%'
      )GROUP BY "Guia"."id","Persona"."id","Persona"."identificacion","Persona"."nombre","Persona"."apellido" --"Persona"."direccion",
      --"Persona"."localidad",
      --"Persona"."email",
      --"Persona"."fecha_nacimiento",
      --"Persona"."telefono",
      --"Persona"."createdAt",
      --"Persona"."updatedAt",
      --"Persona"."deletedAt"  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant