Joined: 28 Jan 2004 Posts: 40 Location: Trivandrum
Q-1: I have the following SQL...
SELECT MIN(SALARY)
FROM TABLE.EMP
WHERE EMPNO = '1025' ;
In case there is no EMPNO '1025' then what would be the O/P
(i) NULL
(i) SQLCODE of +100
Q-2 : I have the following two queries
1. SELECT DEPTNAME, AVG(SALARY)
FROM TABLE.EMP
GROUP BY DEPTNAME;
2. SELECT DEPTNAME, SUM(SALARY)/COUNT(*)
FROM TABLE.EMP
GROUP BY DEPTNAME;
(i) The output of both the queries would be same.
(ii) The output of both the queries would not be same.
(iii) The output of both the queries may or maynot be the same.
Q-3: From the following table write down the query to count the
department numbers.
Ans-2 : (iii) In theory Avg means SUM divided by count but it maynot
return the same value b'cos SUM would ignore nulls
but the count function would count all the values regardless of
nulls. The AVG function just works on the numeric
arguments.
i tried the sum/count(*) and avg but i am getting the same result can u explain how its diffrent value.i have seen in the book(cj.date) that sum and avg will work on numeric.