Home Interview Questions and AnswersTechnical Interview Questions and AnswersDB2 Mainframe DB2 Interview Questions and Answers Part-1

db31.) How would you find out the total number of rows in a DB2 table?

Use SELECT COUNT(*) … in db2 query

2.) How do you eliminate duplicate values in DB2 SELECT ?

Use SELECT DISTINCT … in db2 query

3.) How do you select a row using indexes in DB2?

Specify the indexed columns in the WHERE clause of db2 query.

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

Use SELECT MAX(…) .. in db2 query

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

SQL Query : SELECT SUBSTR(FIRSTNAME,1,5) FROM EMP;

6.) What are aggregate functions?

Bulit-in mathematical functions for use in SELECT clause.

7.) Can you use MAX on a CHAR column?

YES.

8.) My SQL statement SELECT AVG(SALARY) FROM EMP yields inaccurate results. Why?

Because SALARY is not declared to have NULLs and the employees for whom the salary is not known are also counted.

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

SELECT FIRSTNAME || � � || LASTNAME FROM EMP;

10.) What is the use of VALUE function?

1. Avoid -ve SQLCODEs by handling nulls and zeroes in computations

2. Substitute a numeric value for any nulls used in computation

You may also like

Leave a Comment