i have a table
col1
10
20
30
40
10
20
50
my requirement is how to retrive only duplicates like
10
10
20
20
like this how it's possible in SQL?
Answer Posted / subhash
From above all, these 3 are the correct ways using SQL:
A.
select * from emp as p where rowid<(select max(rowid) from
emp s where p.deptno=s.deptno);
B.
select * from sno
where sno in (select sno from emp
group by sno
having count(sno)>1
)
C.
1. SELECT A.COL1 FROM TABLE1 A
2. ( SELECT COL1, COUNT(COL1)FROM TABLE1
GROUP BY (COL1)
HAVING COUNT(COL1)=1)B
WHERE
3. A.COL1<>B.COL1
RESULT : 1. 10 20 30 40 10 20 50
2. 30 40 50
3. 10 10 20 20
And Using DataStage:
A.
Take source and copy,aggregate,JOIN,FILTER
1) give one copy output link to aggr, other to JOIN
2)In arggr perform count rows,
col1 COUNT
10 2
20 2
30 1
40 1
50 1
3) JOIN the two links(link1 from copy, link2 from AGG) and
use LEFT OUTER JOIN
col1 COUNT
10 2
20 2
30 1
40 1
10 2
20 2
50 1
4)And in FILTER, give constrains as count=1 to TARGET1 and
count>1 to TARGET2. in the TARGET2, u will get the desired
output.
| Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
Differentiate between datastage and datastage tx?
What is the difference between Datastage 7.5 and 7.0?
How can you write parallel routines in datastage PX?
what is the difference between == and eq in UNIX shell scripting?
What is ibm datastage flow designer?
How to RD using transformer?
What are sequencers?
Difference between server jobs & parallel jobs?
describe the Steps to confiure a Qlogic switch
What are the types of containers and how to create them?
How can we perform the 2nd time extraction of client database without accepting the data which is already loaded in first time extraction?
In Datastage, how you can fix the truncated data error?
What are some prerequisites for datastage?
Differentiate between hash file and sequential file?
Hi All , in PX Job I have passed 4 Parameters and when i run the same job in sequence i dont want to use those parameters , is this possible if yes then how