Max Analytical Function in Netezza Database syntax only

CREATE TABLE temp_max_analytical_function
(
HHLDNO INTEGER,
STARTDATETIME TIMESTAMP,
SPLIT_GROUP_NUMBER INTEGER
);

INSERT INTO temp_max_analytical_function
select 1111,'2011-11-11 00:00:00',1 union all
select 2222,'2011-11-11 00:01:00',null union all
select 3333,'2011-11-11 00:02:00',null union all
select 4444,'2011-11-11 00:03:00',4 union all
select 5555,'2011-11-11 00:04:00',null union all
select 6666,'2011-11-11 00:05:00',3 union all
select 7777,'2011-11-11 00:06:00',null


select HHLDNO,STARTDATETIMEmax(SPLIT_GROUP_NUMBER) over (partition by HHLDNO order by STARTATETIME)

Result:
1111 2011-11-11 00:00:00 1 1
2222 2011-11-11 00:01:00 null 1
3333 2011-11-11 00:02:00 null 1
4444 2011-11-11 00:03:00 4 4
5555 2011-11-11 00:04:00 null 4
6666 2011-11-11 00:05:00 3 3
7777 2011-11-11 00:06:00 null 3

No comments:

Post a Comment