View previous topic :: View next topic
|
Author |
Message |
harikrishnanrajeev
EXPERT
Joined: 28 Jan 2004 Posts: 37 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.
EMPNO WORKDEPT
1000 SALES
1001 ACCTS
1002 SALES
1003 ACCTS
1004 ACCTS
1005 ADMIN
1006 SALES
1007 ADMIN
1008 ADMIN
1009 MKETG
1010 SALES
1011 MKETG
1012 MKETG
SCROLL DOWN FOR ANSWER.....
Ans-1 : NULL
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.
Ans-3 :
SELECT COUNT(DISTINCT WORKDEPT)
FROM TABLE.EMP;
click below for more DB2 interview questions
[url]http://www.mywirelesskit.com/mainframe-db2.html
[/url] |
|
Back to top |
|
|
ksivapradeep
New User
Joined: 30 Jul 2004 Posts: 95
|
|
|
|
question-1.
hi harikrishna,
according to u i tried this query
test== table name
esal==salary coumn name
eid==primary key
select min(esal) from test where eid=46
o/p: is +100 - record not found
how null comes |
|
Back to top |
|
|
ksivapradeep
New User
Joined: 30 Jul 2004 Posts: 95
|
|
|
|
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.
regards
siva pradeep |
|
Back to top |
|
|
|