There are three ways we can use on WHERE clause on SQL:
orwhere column_name = nvl(:parameter, column_name)
orwhere column_name like nvl(:parameter, '%')
where (column_name = :parameter or :parameter is null)
orwhere column_name = nvl(:parameter, column_name)
orwhere column_name like nvl(:parameter, '%')
where (column_name = :parameter or :parameter is null)
Then you can kill it with (change sid and serial# using result from query above):select s.username,s.sid,s.serial#,s.last_call_et/60 mins_running,q.sql_text from v$session s
join v$sqltext_with_newlines q
on s.sql_address = q.address
where status='ACTIVE'
and type <>'BACKGROUND'
and last_call_et> 60
order by sid,serial#,q.piece
ALTER SYSTEM KILL SESSION 'sid,serial#';
change archivelog until time 'sysdate-x' delete;