IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

DB2 Interview questions


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
harikrishnanrajeev

EXPERT


Joined: 28 Jan 2004
Posts: 37
Location: Trivandrum

PostPosted: Sat Jul 03, 2004 6:12 pm
Reply with quote

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
View user's profile Send private message
ksivapradeep

New User


Joined: 30 Jul 2004
Posts: 95

PostPosted: Mon Sep 13, 2004 5:12 pm
Reply with quote

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
View user's profile Send private message
ksivapradeep

New User


Joined: 30 Jul 2004
Posts: 95

PostPosted: Wed Sep 15, 2004 9:44 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Comp interview questions Mainframe Interview Questions 5
No new posts Interview Questions on Cobol DB2 program Mainframe Interview Questions 5
No new posts The Last Two Question For You To Ask ... Mainframe Interview Questions 0
No new posts Mainframe Interview Questions CICS,CO... Mainframe Interview Questions 6
No new posts Viewing executing process in NDM .. q... IBM Tools 0
Search our Forums:

Back to Top