postgresql - Postgres Complex Select in a View -
i have select clause working perfect:
select "aspectos"."id" "aspecto normativo id", "aspectos"."aspecto" "aspecto normativo", "fatores"."id", "fatores"."fator" "fator normativo", "diagnostico"."vinculo_final", "fatores_1"."id", "fatores_1"."fator" "fator determinativo", "aspectos_1"."id" "aspecto determinativo id", "aspectos_1"."aspecto" "aspecto determinativo", count("itens"."id") "no itens", count("itens"."id") "pri" "diagnostico" inner bring together ("aspectos" "aspectos_1" inner bring together (("fontes" inner bring together "itens" on "fontes"."id" = "itens"."fonte") inner bring together ("fatores" "fatores_1" inner bring together ("aspectos" inner bring together ("vinculos" inner bring together "fatores" on "vinculos"."fator_normativo" = "fatores"."id") on ("aspectos"."id" = "fatores"."aspecto") , ("aspectos"."id" = "fatores"."aspecto")) on "fatores_1"."id" = "vinculos"."fator_determinativo") on "itens"."id" = "vinculos"."item") on "aspectos_1"."id" = "fatores_1"."aspecto") on "diagnostico"."id" = "vinculos"."diagnostico_id" grouping "aspectos"."id", "aspectos"."aspecto", "fatores"."id", "fatores"."fator", "diagnostico"."vinculo_final", "fatores_1"."id", "fatores_1"."fator", "aspectos_1"."id", "aspectos_1"."aspecto" order "aspectos"."id", "aspectos_1"."id", "fatores"."fator", "fatores_1"."fator";
but when seek create view same select i'm getting thuis error:
error: column "id" specified more 1 time
can help me on this. thanks
you have "fatores"."id"
(line 4) , "fatores_1"."id"
(line 6). give them different aliases.
for such complex queries recommended have 1 (one) column in per line in statement improve visibility. recommended give aliases columns.
postgresql select view
No comments:
Post a Comment