How to get the result for my query [message #627039] |
Thu, 06 November 2014 13:23 |
|
venki459
Messages: 5 Registered: November 2014 Location: CHENNAI
|
Junior Member |
|
|
select * from aris_g
Name_dug NO
A 20
A 21
A 50
B 30
B 15
B 45
B 46
Result Output Should Be
Name_dug NO
A 20
21
50
B 30
15
45
46
Name_dug should repeate only once for 'A' and 'B'
|
|
|
|
|
|
|
|
|
Re: How to get the result for my query [message #627089 is a reply to message #627039] |
Fri, 07 November 2014 03:13 |
|
sandeep_orafaq
Messages: 88 Registered: September 2014
|
Member |
|
|
As asked by the forum, you should always provide the create table and data script along with a test case and the work that you have tried. It becomes easy to help in that case.
Based on my assumption, you can use analytical function
SQL> SELECT DECODE(row1,1,Name_dug1,NULL) Name_dug,NO FROM
2 (
3 WITH DATA1 AS
4 (SELECT 'A' Name_dug , 20 NO FROM dual UNION ALL
5 SELECT 'A' Name_dug , 21 NO FROM dual UNION ALL
6 SELECT 'A' Name_dug , 50 NO FROM dual UNION ALL
7 SELECT 'B' Name_dug , 30 NO FROM dual UNION ALL
8 SELECT 'B' Name_dug , 15 NO FROM dual UNION ALL
9 SELECT 'B' Name_dug , 46 NO FROM dual UNION ALL
10 SELECT 'B' Name_dug , 45 NO FROM dual
11 )
12 SELECT Name_dug Name_dug1,NO, ROW_NUMBER() OVER (PARTITION BY name_dug ORDER BY NO) row1 FROM data1
13 ) ORDER BY Name_dug1;
NAME_DUG NO
-------- ----------
A 20
21
50
B 15
30
45
46
7 rows selected
[Updated on: Fri, 07 November 2014 03:16] Report message to a moderator
|
|
|
|
Re: How to get the result for my query [message #627119 is a reply to message #627056] |
Fri, 07 November 2014 06:35 |
|
EdStevens
Messages: 1376 Registered: September 2013
|
Senior Member |
|
|
[quote title=venki459 wrote on Thu, 06 November 2014 20:55]venki459 wrote on Thu, 06 November 2014 13:23we are using oracle10g and oracle 11g
Fine, but we have also been asking/making reference to the fact that the solution has to do with whatever client program you are using. "oracle10g" and "oracle 11g" are just generic names for the database itself. They say nothing about whatever client program you are using.
|
|
|