this was silly from me!
this should naturally look like this:
select case when status ='Closed' then stop_date else start_date end
as adate,
sum(case when status ='Closed' then 1 else 0 end) as
closedCount,
sum(case when status ='New' then 1 else 0 end) as openedCount
fro
select distinct on (Key) Key, Date, Value
from <>
order by Key, Date desc
MYDATABASE=> create table aaa (key varchar(1), date date, value text);
CREATE TABLE
Time: 1518.002 ms
MYDATABASE=> insert into aaa (key, date, value) values ('A',
'2008-05-01', 'foo');
INSERT 0 1
Time: 1.125 ms
MYDATABASE=>
> Raj Mathur wrote:
>
> I have some data of the form:
>
> Key | Date | Value
> A | 2008-05-01 | foo*
> A | 2008-04-01 | bar
> A | 2008-03-01 | foo*
> B | 2008-03-04 | baz
> B | 2008-02-04 | bar
> C | 2008-06-03 | foo*
> C | 2008-04-04 | baz
> C | 2008-03-04 | ba
Howdy, Raju
Do you want somethin like this? Not sure if I fully understood your
requests...
SELECT "Key",MAX(Date)
FROM t_yourTable
WHERE Value LIKE 'foo'
GROUP BY Key ;
Best,
Oliveiros
- Original Message -
From: "Raj Mathur" <[EMAIL PROTECTED]>
To:
Sent: Friday, October 03, 2008 7
I have some data of the form:
Key | Date | Value
A | 2008-05-01 | foo*
A | 2008-04-01 | bar
A | 2008-03-01 | foo*
B | 2008-03-04 | baz
B | 2008-02-04 | bar
C | 2008-06-03 | foo*
C | 2008-04-04 | baz
C | 2008-03-04 | bar
Is there any way to select only the rows ma
Hi,
What about something like that ?
select adate, sum(openedCount) as openedCount, sum(closedCount) as closedCount
from
(
select sum(case when status ='Closed' then stop_date else start_date end) as
adate,
sum(case when status ='Closed' then 1 else 0 end) as closedCount
sum(cas