|
|
Archives of the TeradataForum
Message Posted: Thu, 20 Aug 2015 @ 10:09:46 GMT
Subj: | | Re: Query to return records which are in sequence |
|
From: | | Ganga, Sandeep Kumar |
Hi Gupta Vipin,
Please try below, and see If this helps,
create table hourvalue (hh integer, val Integer);
insert values,
SQL
--------------------------
select sum(val)/ (
SELECT MIN(hh) + 1
FROM hourvalue vh
WHERE NOT EXISTS
(
SELECT NULL
FROM hourvalue hv
WHERE hv.hh = vh.hh + 1))
from hourvalue
where hh < (
SELECT MIN(hh) + 1
FROM hourvalue vh
WHERE NOT EXISTS
(
SELECT NULL
FROM hourvalue hv
WHERE hv.hh = vh.hh + 1))
--------------------------
Thanks,
Sandeep.
GANGA SANDEEP KUMAR
| |