select distinct(empid),distinct(dept),name
from EMP


will the above query work?

Answers were Sorted based on User's Feedback



select distinct(empid),distinct(dept),name from EMP will the above query work?..

Answer / harsha

No, It will not work. SELECT DISTINCT works only for single
cloumn.

DISTINCT can be applied multiple times only when you want
to apply aggregate functions such as COUNT, AVG & SUM.
e.g.
SELECT COUNT(EMPNO)/COUNT(DISTINCT(WORKDEPT)), COUNT
(DISTINCT(JOB))
FROM DSN8810.EMP

Is This Answer Correct ?    14 Yes 1 No

select distinct(empid),distinct(dept),name from EMP will the above query work?..

Answer / chidambara subbu

No, It will not work. We can select DISTINCT values for
multiple columns however not all the columns will give
ditint value. For intance , see below table TABLE1
Name City
XXX Chennai
FFF HYD
XXX Blore
YYY Mumbai

1.SELECT DISTINCT NAME FROM TABLE1
Name
XXX
FFF
YYY
2. SELECT DISTINCT NAME,City FROM TABLE1
Name City
XXX Chennai
FFF HYD
XXX Blore
YYY Mumbai

See the result of second query. It has selected duplicate
entry 'XXX' in the Name column.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More DB2 Interview Questions

what is the use of bind parameter, Replace?

5 Answers   IBM,


What is the difference between static and dynamic SQL?

1 Answers  


In which column of which DB2 catalog would you find the length of the rows for all tables?

2 Answers  


Q1. How will you use two different DB2 qualifiers in a single COBOL program? Suppose we have 2 tables EMP1 and EMP2 with same structure defined in two different DB2 qualifiers QUAL1.EMP1 and QUAL2.EMP2 now during first 15 days we want to use QUAL1.EMP1 and rest of the days QUAL2.EMP2  how will we do this.  We can create a single program and a single load for this program. 

2 Answers   RBS,


How can you quickly find out the number of rows updated after an update statement?

1 Answers   CSI, CTS,






What is the advantage in De-normalizing tables in DB2?

0 Answers  


How do I change the column size in db2?

0 Answers  


What is the use of with ur in db2?

0 Answers  


What is db2?

0 Answers  


Define db2.

0 Answers  


How to select the duplicate rows from a table?

4 Answers  


select * from orders where odate between '2010-01-01'and '2010-03-31' How do u fetch this into cursor?

2 Answers  


Categories