Subqueries - Mailing list pgsql-sql

From Pascal Tufenkji
Subject Subqueries
Date
Msg-id 003e01c93a89$7eea61b0$150fa8c0@interne.usj.edu.lb
Whole thread Raw
Responses Re: Subqueries
List pgsql-sql
<div class="Section1"><p class="MsoNormal"><font face="Verdana" size="2"><span style="font-size:10.0pt;
font-family:Verdana">Hello,</span></font><p class="MsoNormal"><font face="Verdana" size="2"><span
style="font-size:10.0pt;
font-family:Verdana"> </span></font><p class="MsoNormal"><font face="Verdana" size="2"><span style="font-size:10.0pt;
font-family:Verdana">I don’t understand the following error.</span></font><p class="MsoNormal"><font face="Verdana"
size="2"><spanstyle="font-size:10.0pt; 
font-family:Verdana">Can anyone help me plz</span></font><p class="MsoNormal"><font face="Verdana" size="2"><span
style="font-size:10.0pt;
font-family:Verdana">Thx</span></font><p class="MsoNormal"><font face="Verdana" size="2"><span style="font-size:10.0pt;
font-family:Verdana">Pascal </span></font><p class="MsoNormal"><font face="Verdana" size="2"><span
style="font-size:10.0pt;
font-family:Verdana"> </span></font><p class="MsoNormal"><font face="Courier New" size="2"><span
style="font-size:10.0pt;
font-family:"Courier New"">select *</span></font><p class="MsoNormal"><font face="Courier New" size="2"><span
style="font-size:10.0pt;
font-family:"Courier New"">from sip_vacations_v v</span></font><p class="MsoNormal"><font face="Courier New"
size="2"><spanstyle="font-size:10.0pt; 
font-family:"Courier New"">left join</span></font><p class="MsoNormal"><font face="Courier New" size="2"><span
style="font-size:10.0pt;
font-family:"Courier New"">(</span></font><p class="MsoNormal"><font face="Courier New" size="2"><span
style="font-size:10.0pt;
font-family:"Courier New"">      select pe.emp_id,mg.mat_id,mg.groupe,count(p.id) * 1.5 as nb_heures</span></font><p
class="MsoNormal"><fontface="Courier New" size="2"><span style="font-size:10.0pt; 
font-family:"Courier New"">      from mat_grp_v mg</span></font><p class="MsoNormal"><font face="Courier New"
size="2"><spanstyle="font-size:10.0pt; 
font-family:"Courier New"">      inner join planification_v p on p.mat_grp_id = mg.id</span></font><p
class="MsoNormal"><fontface="Courier New" size="2"><span style="font-size:10.0pt; 
font-family:"Courier New"">      </span></font><font face="Courier New" size="2"><span lang="FR"
style="font-size:10.0pt;font-family:
"Courier New"">inner join planification_ens_v pe on pe.planification_id = p.id</span></font><p class="MsoNormal"><font
face="CourierNew" size="2"><span lang="FR" style="font-size:10.0pt;font-family:"Courier New"">     
</span></font><b><fontface="Courier New" size="2"><span style="font-size:10.0pt;font-family:"Courier New"; 
font-weight:bold">where mg.annee_univ = v.annee and mg.semestre = v.sem_civ</span></font></b><p class="MsoNormal"><font
face="CourierNew" size="2"><span style="font-size:10.0pt; 
font-family:"Courier New"">      group by pe.emp_id,mg.mat_id,mg.groupe</span></font><p class="MsoNormal"><font
face="CourierNew" size="2"><span style="font-size:10.0pt; 
font-family:"Courier New"">) p on p.emp_id = v.emp_id</span></font><p class="MsoNormal"><font face="Courier New"
size="2"><spanstyle="font-size:10.0pt; 
font-family:"Courier New"">      and p.mat_id = v.mat_id</span></font><p class="MsoNormal"><font face="Courier New"
size="2"><spanstyle="font-size:10.0pt; 
font-family:"Courier New"">      and p.groupe = v.groupe</span></font><p class="MsoNormal"><font face="Courier New"
size="2"><spanstyle="font-size:10.0pt; 
font-family:"Courier New""> </span></font><p class="MsoNormal"><b><font color="red" face="Courier New" size="2"><span
style="font-size:10.0pt;font-family:"CourierNew";color:red;font-weight:bold">ERROR:  invalid reference to FROM-clause
entryfor table "v"</span></font></b><p class="MsoNormal"><b><font color="red" face="Courier New" size="2"><span
style="font-size:10.0pt;font-family:"CourierNew";color:red;font-weight:bold">LINE 9: where mg.annee_univ = v.annee and
mg.semestre= v.sem_civ</span></font></b><p class="MsoNormal"><b><font color="red" face="Courier New" size="2"><span
style="font-size:10.0pt;font-family:"CourierNew";color:red;font-weight:bold">                             
^</span></font></b><pclass="MsoNormal"><b><font color="red" face="Courier New" size="2"><span
style="font-size:10.0pt;font-family:"CourierNew";color:red;font-weight:bold">HINT:  There is an entry for table "v",
butit cannot be referenced from this part of the query.</span></font></b><p class="MsoNormal"><font face="Verdana"
size="2"><spanstyle="font-size:10.0pt; 
font-family:Verdana"> </span></font><p class="MsoNormal"><font face="Verdana" size="2"><span style="font-size:10.0pt;
font-family:Verdana"> </span></font><p class="MsoNormal"><font face="Verdana" size="2"><span style="font-size:10.0pt;
font-family:Verdana"> </span></font></div>

pgsql-sql by date:

Previous
From: gherzig@fmed.uba.ar
Date:
Subject: Re: trying to repair a bad header block
Next
From: "Oliveiros Cristina"
Date:
Subject: Re: Subqueries