Re: Subqueries - Mailing list pgsql-sql

From Oliveiros Cristina
Subject Re: Subqueries
Date
Msg-id 029501c93a8d$ff15d370$ec5a3d0a@marktestcr.marktest.pt
Whole thread Raw
In response to Subqueries  ("Pascal Tufenkji" <ptufenkji@usj.edu.lb>)
List pgsql-sql
alias v not visible in sub-query?
----- Original Message -----
Sent: Thursday, October 30, 2008 12:17 PM
Subject: [SQL] Subqueries

Hello,

 

I don’t understand the following error.

Can anyone help me plz

Thx

Pascal

 

select *

from sip_vacations_v v

left join

(

      select pe.emp_id,mg.mat_id,mg.groupe,count(p.id) * 1.5 as nb_heures

      from mat_grp_v mg

      inner join planification_v p on p.mat_grp_id = mg.id

      inner join planification_ens_v pe on pe.planification_id = p.id

      where mg.annee_univ = v.annee and mg.semestre = v.sem_civ

      group by pe.emp_id,mg.mat_id,mg.groupe

) p on p.emp_id = v.emp_id

      and p.mat_id = v.mat_id

      and p.groupe = v.groupe

 

ERROR:  invalid reference to FROM-clause entry for table "v"

LINE 9: where mg.annee_univ = v.annee and mg.semestre = v.sem_civ

                              ^

HINT:  There is an entry for table "v", but it cannot be referenced from this part of the query.

 

 

 

pgsql-sql by date:

Previous
From: "Pascal Tufenkji"
Date:
Subject: Subqueries
Next
From: "Helio Campos Mello de Andrade"
Date:
Subject: Re: Subqueries