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 are the four lockable units for DB2?

1 Answers  


What is the STOSPACE Utility used for?

1 Answers  


What is the meaning of -805 SQL return code?

3 Answers  


insert into tablename a column1, column2 select column1, column2 from tablename b i am getting abend -104..can any one help?

3 Answers   Syntel,


Define buffer pool.

0 Answers  


How does DB2 store NULL physically?

2 Answers  


What are iseries servers?

0 Answers  


what is Static and dynamic linking

1 Answers   Virtusa,


What is difference between alias and synonym in db2?

0 Answers  


How to check sequence on a table in db2?

0 Answers  


In db2, how do you insert multiple rows in 1 query using a.) Cursors, b.) Normal query?? Give syntax for both.

5 Answers   CTS,


Explain transactions, commits and rollbacks in DB2.

3 Answers  


Categories