How do I get the nth(2nd) row from a list of results and if the 2nd row (column 2) is a certain number do not print anything.
Select * from
(select s.id_numeric,
s.client_id,
s.depth,
s.fas_sample_type,
s.profile_number,
Count(1) over() as cnt
from sample s
where s.client_id = upper ('128336A')
and s.id_numeric between 12325 and 12327
and s.fas_sample_type = sample_pkg.get_soil_sample
and s.status = sample_pkg.get_authorised_sample
and s.flg_released = constant_pkg.get_true)
Where cnt > 1
Hmm, I thought it would be easy but it took me about 10 minutes to solve.
select *
from (select rownum row_num,
/* here_goes_rest_of_subquery */
fetch first 2 rows only) sub_q
where ...
order by sub_q.row_num desc
fetch first 1 row only;
Please note your subquery has no "order by" part and you want the nth row of the result. Thus you may end up getting different results on different clients.
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.