On 04/29/2010 05:08 PM, Thomas Kellerer wrote:
SELECT organization, state, lastdate, age(lastdate)
FROM (
SELECT organization,
state,
(select max(idate) from times where
customers.custid=times.custid and taskid = 27) as lastdate
FROM customers
) t
order by lastdate desc
Andy Colson wrote on 29.04.2010 23:51:
Here is my query, which works:
select organization,
state,
(select max(idate) from times where customers.custid=times.custid and
taskid = 27) as lastdate,
age( (select max(idate) from times where customers.custid=times.custid
and taskid = 27) )
from custom
On 4/29/2010 4:51 PM, Andy Colson wrote:
I tried this:
select organization, state, max(idate), age(max(idate))
from customers
inner join times using(custid)
where taskid = 27
group by organization, state
order by idate desc nulls last;
but get error that times.idate must appear in group by or
Here is my query, which works:
select organization,
state,
(select max(idate) from times where customers.custid=times.custid and
taskid = 27) as lastdate,
age( (select max(idate) from times where
customers.custid=times.custid and taskid = 27) )
from customers
order by lastdate desc null