Question : Oracle Sql Query error

SQL> set lines 132
SQL> column event format a35
SQL> compute sum of cnt on report
SQL> break on report
SQL> set heading on
SQL> set pagesize 100
SQL> select a.event, count(*) cnt,
  2  min(SECONDS_IN_WAIT) min_wait,
  3  round(avg(SECONDS_IN_WAIT)) avg_wait,
  4  max(SECONDS_IN_WAIT) max_wait
  5  from v$session_wait a, v$session b
  6  where a.sid > 7
  7  and b.sid = a.sid
  8  and b.status = 'ACTIVE'
  9  group by a.event
 10  order by 2 desc;
max(SECONDS_IN_WAIT) max_wait
    *
ERROR at line 4:
ORA-00918: column ambiguously defined

Hi guys when iam trying to run this query its showing above error so can you please help me out to solve this problem

Answer : Oracle Sql Query error

the column SECONDS_IN_WAIT is present in both views contained in your query, so you need to specify which one you want.  So, if you want the one from V$SESSION_WAIT then use the following:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
select a.event, 
	count(*) cnt,
	min(a.SECONDS_IN_WAIT) min_wait,
	round(avg(a.SECONDS_IN_WAIT)) avg_wait,
	max(a.SECONDS_IN_WAIT) max_wait
from v$session_wait a, v$session b
where a.sid > 7
    and b.sid = a.sid
    and b.status = 'ACTIVE'
group by a.event
order by 2 desc;
Random Solutions  
 
programming4us programming4us