-
Hi
break on deptno;
select deptno,empno,ename,sal from emp order by deptno;
The above sql query will suppress the deptno duplicate value. Is it possible to write a query and get the same result with out using break on deptno?
rammi
-
If i'm not wrong, u can use distinct for the deptno in the select query, this also avoids duplicates . but the thing is u've to specify the distinct only for one column and should be the first column in the select clause.
Pls correct me any gurus , if i'm wrong
PNRDBA
-
Hi
Using distinct will not solve the problem, if i am correct.
rammi
-
Hi ramya_ram,
What exactly are you trying to do?
-
Hi SC
I want query to run where I can not use break on.
rammi
-
Hi,
break on ... is a command of SQL*Plus and has nothing to do with SQL.
You cannot suppress duplicate values in a resultset of a single SQL query.
Ales
-
I do not understand what you want.
First possibility:Yes, distinct will return distinct values of the entire result set, you are right. But you want only once dept. no, and combined with another columns in some result set. Logically, if you will not restrict some way the other combination in the result set, you have to have more that one row for one value of dept.no.
Now think: you could use group by deptno. But, because the group by was very logically thinked, you will have to put in your group by list all the columns in select_list that are not agregates or constants. This is very logically stated! This is how the truth comes to the light.
You want once every deptno, but with which values of employee etc.?
Then, the other possible thread: you want all the values, but you want to display deptno only once. Then, this is a client issue. Solve in client or in sqlplus.
ovidius over!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|