Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

DB2 Interview questions

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: DB2 Interview questions
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    Post subject:
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    Post subject: Re: DB2 Interview questions
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Viewing executing process in NDM .. q... Debb.Brant IBM Tools 0 Wed Dec 14, 2016 10:55 pm
No new posts INCLUDE condition questions van bui DFSORT/ICETOOL 1 Thu Jun 30, 2016 9:52 am
No new posts SAS Programming - Basic Questions Techelm All Other Mainframe Topics 3 Fri Mar 18, 2016 10:53 pm
No new posts Where can i find Interview questions ... Elixir Mainframe Interview Questions 4 Sat Feb 20, 2016 12:38 am
This topic is locked: you cannot edit posts or make replies. Mainframe interview on 10th Oct 2015 ... kotesh Mainframe Jobs 0 Thu Oct 08, 2015 5:21 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us