oracle 9i [message #432080] |
Fri, 20 November 2009 23:47  |
ramesh55.sse
Messages: 262 Registered: December 2008 Location: Hyderabad
|
Senior Member |
|
|
Hi experts goo morning
I want to retrieve first two rows along with two null values for each group.
the data as follows
deptno sal
10 2000
10 3000
10
20 4000
20 5000
20
20
30 1000
30 3000
30 2000
30 5000
30
30
In this scenario the output should like this
20 4000
20 5000
20
20
30 1000
30 3000
30 2000
30 5000
30
30
please help me thanks in advance
|
|
|
|
|
|
|
Re: oracle 9i [message #432264 is a reply to message #432080] |
Mon, 23 November 2009 05:35   |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
Based on the results that you posted,I assume that the question that you meant to ask was' How can I show all the rows from each group that contains at least two null values'
I would base my query on something like this:
SELECT group_id
FROM table
having sum(nvl2(column,0,1))>2
|
|
|
Re: oracle 9i [message #432437 is a reply to message #432264] |
Tue, 24 November 2009 04:19  |
Its_me_ved
Messages: 979 Registered: October 2009 Location: India
|
Senior Member |
|
|
Sir, I think it should be '>='
SELECT group_id
FROM table
group by group_id
having sum(nvl2(column,0,1))>= 2
Regards,
Ved
|
|
|