DB2 Interview Questions and Answers:Part 1

10/31/2009 No Comment

IBM Mainframe DB2 Questions and Answers.

How would you find out the total number of rows in a DB2 table?
Answer : Use SELECT COUNT(*) ... in db2 query

How do you eliminate duplicate values in DB2 SELECT?
Answer : Use SELECT DISTINCT ... in db2 query

How do you select a row using indexes in DB2?
Answer : Specify the indexed columns in the WHERE clause of db2 query.

How do you find the maximum value in a column in db2?

Answer : Use SELECT MAX(...) .. in db2 query

How do you retrieve the first 5 characters of FIRSTNAME column of DB2 table EMP ?


What are aggregate functions?

Answer : Bulit-in mathematical functions for use in SELECT clause.

Can you use MAX on a CHAR column?

Answer : YES.

My SQL statement SELECT AVG(SALARY) FROM EMP yields inaccurate results. Why?
Answer : Because SALARY is not declared to have NULLs and the employees for whom the salary is not known are also counted.

How do you concatenate the FIRSTNAME and LASTNAME from EMP table to give a complete name?


What is the use of VALUE function?

Answer : 1. Avoid -ve SQLCODEs by handling nulls and zeroes in computations
2. Substitute a numeric value for any nulls used in computation

What is the restriction on using UNION in embedded SQL?

Answer : It has to be in a CURSOR.

In the WHERE clause what is BETWEEN and IN?

Answer : BETWEEN supplies a range of values while IN supplies a list of values.

Is BETWEEN inclusive of the range values specified?
Answer : Yes.

What is 'LIKE' used for in WHERE clause? What are the wildcard characters?

Answer : LIKE is used for partial string matches. ‘%’ ( for a string of any character ) and ‘_’ (for any single character ) are the two wild card characters.

When do you use a LIKE statement?

Answer : To do partial search e.g. to search employee by name, you need not specify the complete name; using LIKE, you can search for partial string matches.

What is the meaning of underscore ( ‘_’ ) in the LIKE statement?

Answer : Match for any single character.

What do you accomplish by GROUP BY ... HAVING clause?

Answer : GROUP BY partitions the selected rows on the distinct values of the column on which you group by. HAVING selects GROUPs which match the criteria specified

Consider the employee table with column PROJECT nullable. How can you get a list of employees who are not assigned to any project?
Related Posts

No comments :


Aired | The content is copyrighted and may not be reproduced on other websites. | Copyright © 2009-2016 | All Rights Reserved 2016

Contact Us | About Us | Privacy Policy and Disclaimer