select distinct(empid),distinct(dept),name
from EMP
will the above query work?
Answers were Sorted based on User's Feedback
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 |
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 |
wht happens if we close cursor with cursor with hold option?
Is ibm db2 free?
What is the difference between TYPE 1 index & TYPE 2 index
How to execute stored procedures?
How to define the data items to receive the fetch items for the SQL?
Explain the function of data manager.
In cursor program-1 can we create another cursor program-2 inside the cursor program-1.If yes how/no why ?
What are PACKAGES ?
What is the maximum length of a column name in DB2? 18 or 30 or anything other than these?
What is DCLGEN?
What is an instance in db2?
what is + sign and -ve sign for sql code ?