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 cursor stability?

1 Answers  


Mention the location where the output received from explain statement is stored.

0 Answers  


which is the most efficient tablespace?? a.simple tablespace. b.partitioned tablespace. c.segmented tablespace. d.none of the above. please post answer with the reason.?

3 Answers  


List some fields from sqlca?

0 Answers  


What is a collection in db2?

0 Answers  






How would one remove old reorg information from the DB2 catalog?

2 Answers  


What are the two types of logging in the db2 database? Explain them.

0 Answers  


How many sub queries can you combine together ?

4 Answers   IBM,


What does the sqlcode of -818 pertain to?

3 Answers  


What does this mean ? GRANT BIND,EXECUTE ON PLAN MK2 TO PUBLIC;

4 Answers   Accenture,


Why do chiropractors use drop table?

0 Answers  


How does DB2 store NULL physically?

2 Answers  


Categories