Joseph,
Please take a look at my example again:
> > SELECT tbla.a, tbla.b, total_b
> > FROM tbla,
> > (SELECT b, sum(f) as total_b FROM tblb GROUP BY b) b_tot
> > WHERE tbla.b = b_tot.b
> >
> OK when I tried to convert the query:
> select u.field1, ... , d.field1, ..., mll.lastml FROM utable u,
> dtable d,(select ml.field
> as lastml from ml WHERE ml.key = u.key order by ml.keyfield desc
> limit 1) mll WHERE u.key
> = d.key and ... and lastml = 2;
You need to put the JOIN condition from the subselect ("ml.key = u.key")
OUTSIDE the subselect ("ml.key = mll.key"). You can't reference columns
from the main select inside a subselect except in an EXISTS clause.
This does mean that you're going to need some approach other than the
"limit 1" to limit the rows in your result set. Probably at GROUP BY.
-Josh
P.S. I'm sure you don't mean for your e-mails to come across as
antagonistic when you are asking for help. Can you please be careful of
your phrasing?
______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology [EMAIL PROTECTED]
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?
http://www.postgresql.org/search.mpl