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 |
how can we find nth max salary from A table
What is null in db2?
What are PACKAGES ?
How to get Top 10 Salaries from a Table
How do you stop a db2 database in linux?
What is the physical storage length of each of the following DB2 data types: DATE, TIME, TIMESTAMP?
What does DSNDB07 database do?
Explain an outer join?
Explain about mirror activator disk mirroring?
In BIND, isolation level parameter specifies the duration of page lock and ACQUIRE, RELEASE also do almost the same thing. What is the exact difference between the two? Do they work in conjunction while executing SQL queries and obtaining locks?
What is reorg in database?
What if , we failed to mentioed null indicator in sql select query , that may retrieve null value ?