Click here to Skip to main content
15,891,649 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
My table name is emp;

Fields:

EMPID int, EMPNAME char(50), salary float

I want greater than avg salary in oracle. Please help me.

Thank you.
Posted
Updated 19-Jul-15 20:30pm
v2

1 solution

This would work for you, in Oracle.

SQL
SELECT * -- Finally select the records
FROM table_name -- Table
WHERE column_name > (SELECT AVG(column_name) FROM table_name) -- Condition 


You need to select a value to compare against, select the average value and then compare against the column you want to get. For more using AVG() function in Oracle SQL, read this Stack Overflow thread[^].
 
Share this answer
 
Comments
Wendelius 20-Jul-15 3:46am    
Would work in Oracle but also in majority of SQL databases :)

Nice answer, +5.
Afzaal Ahmad Zeeshan 20-Jul-15 5:22am    
Thank you, Mika.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900