Home » SQL & PL/SQL » SQL & PL/SQL » to get average sal without using average clause
to get average sal without using average clause [message #197042] Mon, 09 October 2006 13:03 Go to next message
ashish_pass1
Messages: 114
Registered: August 2006
Location: delhi
Senior Member
hello
i want to display the avg(sal) from emp. table without using average clause.
thanxx
Re: to get average sal without using average clause [message #197046 is a reply to message #197042] Mon, 09 October 2006 13:14 Go to previous messageGo to next message
Mohammad Taj
Messages: 2412
Registered: September 2006
Location: Dubai, UAE
Senior Member

select sum(sal)/count(sal) from table;
Re: to get average sal without using average clause [message #197049 is a reply to message #197046] Mon, 09 October 2006 13:30 Go to previous messageGo to next message
ashish_pass1
Messages: 114
Registered: August 2006
Location: delhi
Senior Member
thank you dear
Re: to get average sal without using average clause [message #197109 is a reply to message #197042] Tue, 10 October 2006 01:57 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
Why?
The AVG is there for a reason - to calculate averages.
Or is this homework?
Re: to get average sal without using average clause [message #197317 is a reply to message #197042] Tue, 10 October 2006 23:50 Go to previous messageGo to next message
shahidmughal
Messages: 91
Registered: January 2006
Location: Faisalabad Pakistan
Member

hi
it seems you are preparing some assignments

ok dear

here is your solution

SQL> select sum(sal)/count(1) from emp;

SUM(SAL)/COUNT(1)
-----------------
2073.2143

SQL> select avg(sal) from emp;

AVG(SAL)
---------
2073.2143


i have given the both

regards
Muhammad Shahid Mughal
Re: to get average sal without using average clause [message #197329 is a reply to message #197317] Wed, 11 October 2006 00:07 Go to previous message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
Muhammad, I don't think it's useful to copy/paste or repeat answers already given by another member. Look at user52's reply.

Closed.

http://www.orafaq.com/forum/fa/448/0/

MHE
Previous Topic: Why DBMS_STATS.GATHER_TABLE_STATS is not working
Next Topic: pls help i have some queries!
Goto Forum:
  


Current Time: Sun Dec 11 02:16:42 CST 2016

Total time taken to generate the page: 0.19163 seconds