WITH vs AS (
SELECT
ROWNUM rnum,
inst_id,
sid,
serial#,
status,
username,
last_call_et,
command,
machine,
osuser,
module,
action,
resource_consumer_group,
client_info,
client_identifier,
type,
terminal,
sql_id,
sql_child_number
FROM
gv$session
)
SELECT
vs.inst_id,
vs.sid,
serial# serial,
vs.sql_id,
vs.sql_child_number,
vs.username "Username",
CASE
WHEN vs.status = 'ACTIVE' THEN last_call_et
ELSE NULL
END "Seconds in Wait",
(
SELECT
command_name
FROM
v$sqlcommand
WHERE
command_type = vs.command
) "Command",
vs.machine "Machine",
vs.osuser "OS User",
lower(vs.status) "Status",
vs.module "Module",
vs.action "Action",
vs.resource_consumer_group,
vs.client_info,
vs.client_identifier
FROM
vs
WHERE
vs.username IS NOT NULL
AND nvl(vs.osuser,'x') <> 'SYSTEM'
AND vs.type <> 'BACKGROUND'
AND module = 'e:ONT:frm:OEXOEORD'
ORDER BY
1,
2,
3;
SELECT
ROWNUM rnum,
inst_id,
sid,
serial#,
status,
username,
last_call_et,
command,
machine,
osuser,
module,
action,
resource_consumer_group,
client_info,
client_identifier,
type,
terminal,
sql_id,
sql_child_number
FROM
gv$session
)
SELECT
vs.inst_id,
vs.sid,
serial# serial,
vs.sql_id,
vs.sql_child_number,
vs.username "Username",
CASE
WHEN vs.status = 'ACTIVE' THEN last_call_et
ELSE NULL
END "Seconds in Wait",
(
SELECT
command_name
FROM
v$sqlcommand
WHERE
command_type = vs.command
) "Command",
vs.machine "Machine",
vs.osuser "OS User",
lower(vs.status) "Status",
vs.module "Module",
vs.action "Action",
vs.resource_consumer_group,
vs.client_info,
vs.client_identifier
FROM
vs
WHERE
vs.username IS NOT NULL
AND nvl(vs.osuser,'x') <> 'SYSTEM'
AND vs.type <> 'BACKGROUND'
AND module = 'e:ONT:frm:OEXOEORD'
ORDER BY
1,
2,
3;