| Need to write an Select for the following result [message #305010] |
Fri, 07 March 2008 08:55  |
tptbalaji
Messages: 3 Registered: July 2006 Location: us
|
Junior Member |
|
|
hi,
For the following result i need to write a SQL command, is there any body can write it for me.
Col1 Col2 Col3 Col4
XXX 123 a b
XXX 456 a b
XXX 789 a b
XXX 321 a b
Conditions
Need to display Cols only when it has same value for more than once(means at least 2) with various Cols2,Col3,Col4 values
select Col1,Col2,Col3,Col4 from Table A,Table B
where
A.Key = B.key
having count(Col1) >1
group by
Col1,Col2,Col3,Col4
wont give result b'use i dont want to group by Cols2. And i dont want to write a Procedure too. Can we solve thru SQL ?
Any help ? ? ?
|
|
|
|
|
|
|
|
|
|
| Re: Need to write an Select for the following result [message #305020 is a reply to message #305017] |
Fri, 07 March 2008 09:35   |
tptbalaji
Messages: 3 Registered: July 2006 Location: us
|
Junior Member |
|
|
Some more info.
create table t1(col1 number(1) primary key,col2 varchar2(20),col3 varchar2(20));
insert into t1 values(1,'john','alason');
insert into t1 values(2,'steve','pop');
insert into t1 values(3,'williom','John');
create table t2(c1 number(1),c2 varchar2(20),c3 varchar2(20));
insert into t2 values(1,'xxx','123');
insert into t2 values(1,'xxx','456');
insert into t2 values(1,'xxx','789');
insert into t2 values(2,'xxx','123');
insert into t2 values(2,'xxx','987');
insert into t2 values(3,'xxx','567');
The expected result
1 xxx 123 John alason
456 John alason
789 John alason
2 xxx 123 steve pop
987 steve pop
Conditions
Need to list only the rows which are having more than one in t2 Table.
|
|
|
|
|
|
|
|
|
|