Доброго времени.
Помогите найти ошибку, вроде все правильно, а запрос не выполняется...
SELECT a1.idemandid,a1.vcnumber,f_ipeopleid_to_name_fb(a1.ipeopleid) AS fio,a1.dtstart,a1.dtend, b1.dtmonth,b1.m_sum, с1.dtstart,с1.u_sum FROM demand a1, (SELECT b2.idemandid,b2.dtmonth,sum(b2.decsum) AS m_sum FROM demand a2,fixservlgot b2 WHERE a2.istpdemid=29022 AND a2.idemandid=b2.idemandid GROUP BY b2.idemandid,b2.dtmonth ) b1 LEFT OUTER JOIN (SELECT b3.idemandid,b3.dtstart,sum(b3.decsum) AS u_sum FROM demand a3,debt b3 WHERE a3.istpdemid=29022 AND a3.idemandid=b3.idemandid GROUP BY b3.idemandid,b3.dtstart) c1 ON (c1.idemandid=a1.idemandid AND c1.dtstart=b1.dtmonth) WHERE a1.istpdemid=29022 AND a1.idemandid=b1.idemandid ORDER BY 2;
ERROR: invalid reference to FROM-clause entry for table "a1"
LINE 17: (c1.idemandid=a1.idemandid and c1.dtstart=b1.dtmonth)
^
HINT: There is an entry for table "a1", but it cannot be referenced from this part of the query.
Всем спасибо! нашел ошибку...