I just wanted to say thanks to everyone for your help.
-Jeff
This email is intended only for the individual or entity to which it is
addressed. This email may contain information that is privileged, confidential
or otherwise protected from disclosure. Dissemination, distribution or copying
of
"Demel, Jeff" <[EMAIL PROTECTED]> writes:
> Here's what I came up with:
> SELECT customers.id, customers.firstname,
> customers.lastname, customers.phone number,
> (SELECT ar.billdate FROM ar
> WHERE customers.customerid = ar.customerid
> ORDER BY ar.billdate LIMIT 1)
> AS l
, 2007 11:09 AM
To: Demel, Jeff; pgsql-general@postgresql.org
Subject: RE: [GENERAL] Subqueries - performance and use question
sorry, missing GROUP BY and some column naming was messed up but
hopefully you get the idea:
SELECT
c.id,
c.firstname,
c.lastname,
a.latest_billdate
FROM
customers c
ql-general@postgresql.org
> Subject: Re: [GENERAL] Subqueries - performance and use question
>
> try this approach:
>
> SELECT
> c.id,
> c.firstname,
> c.lastname,
> a.latest_billdate
> FROM
> customers c
> INNER JOIN -- or LEFT if you want the NU
try this approach:
SELECT
c.id,
c.firstname,
c.lastname,
a.latest_billdate
FROM
customers c
INNER JOIN -- or LEFT if you want the NULLs
(
SELECT
customer_id,
max(billdate) as latest_billdate
FROM
ar
) a
ON
c.customerid = a.customerid
WHERE
c.status = 'new';