I'm missing one piece of the puzzle. I want to select the first row on strid
order by c_date
and group by strid
.
My sql is:
--there should be some 'FIRST' function on strid
select strid over(partition by strid order by c_date)
from tab
where c_date > :1
and c_date <= :2
tab
strid VARCHAR2(255 CHAR)
c_date TIMESTAMP(6) WITH TIME ZONE
I can use row_number
and then select where row_number=1
but i'm trying to avoid this sub-query, and i'm searching for something more optimized..
Try first_value
:
-- do you really want to partition by strid?
select first_value(strid) over (partition by strid order by c_date)
from tab
where (c_date > :1)
and (c_date <= :2)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.