i/p o/p1 o/p2
1 1 4
1 1 5
1 1 6
2 2
2 2
2 2
3
3
4
5
6
how to populates i/p rows into o/p1&o/p2 using datastage
stages?and also the same scenario using sql?

Answers were Sorted based on User's Feedback



i/p o/p1 o/p2 1 1 4 1 ..

Answer / radhakant kumar

1)by sql say the column name is Id then
a)(for duplicate)
select a.id
from table_name a
left outer join(select id,count(*)as no1
from table_name
group by id
)b
on b.id=a.id
where b.no1>1
order by a.id
it will display 1 1 1 2 2 3 3
b)change the condition where b.no1=1 then it will display
the remainings without duplicates..
2) By DataStage
Step By Step....
a)after source file take Copy stage and draw two
output links
b)one will go to Aggregate stage and take count of
rows by group by Field(id)
it will display like.
ID Count(no)
1 3
2 3
3 2
4 1
5 1
6 1
c)and then use lookup stage main stream will be second link
of copy and reference will be output of Aggregate stage
d)look up key will be ID and fetch count(no) to target
it will display
ID Count(no)
1 3
1 3
1 3
2 3
2 3
2 3
3 2
3 2
4 1
5 1
e)and after lookup stage take transformer or filter stage
by taking two output links and put condition
a)for duplicates count(no)>1
b)for non duplicates count(no)=1

Finally u will get your desired output..
6

Is This Answer Correct ?    13 Yes 1 No

i/p o/p1 o/p2 1 1 4 1 ..

Answer / kalpana_241871

SQL>

SELECT COL1 FROM TAB1 GROUP BY COL1 HAVING COUNT(*) > 1 ;

O/P 1 :
1
1
1
2
2
2
3
3
SQL>

SELECT COL1 FROM TAB1 GROUP BY COL1 HAVING COUNT(*) = 1 ;

O/P 2 :
4
5
6

Is This Answer Correct ?    11 Yes 2 No

i/p o/p1 o/p2 1 1 4 1 ..

Answer / subhash

SQL> small correct in Query provided by Kalpana.

SELECT COL1 FROM TAB1 WHERE COL1 IN
(SELECT COL1 FROM TAB1 GROUP BY COL1 HAVING COUNT(*) > 1) ;

O/P 1 :
1
1
1
2
2
2
3
3
SQL>

SELECT COL1 FROM TAB1 GROUP BY COL1 HAVING COUNT(*) = 1 ;

O/P 2 :
4
5
6

Is This Answer Correct ?    5 Yes 0 No

i/p o/p1 o/p2 1 1 4 1 ..

Answer / kavitha

sequentialfile-----copy-----head and tail(in that we have options like no of rows=6 for head and n..o..r=4 for tail)then connect two data sets to that head and tail u will get

Is This Answer Correct ?    1 Yes 0 No

i/p o/p1 o/p2 1 1 4 1 ..

Answer / rvanaja.etldeveloper@gmail.com

just read the data in sequential file
and take aggregator
group=cid
aggregation type=count rows
count output column=countno
then take filter from filter you drag 2 links for two outputs
in filter write conditions like bellow and give link order
where clause=countno>1
and
where clause=countno=1
map in output links
seqfile-->aggregator-->filter-->2 torgets

Is This Answer Correct ?    0 Yes 0 No

i/p o/p1 o/p2 1 1 4 1 ..

Answer / kalpana_241871

hgfh

Is This Answer Correct ?    0 Yes 1 No

i/p o/p1 o/p2 1 1 4 1 ..

Answer / vijaya

Hi

first sort the input date then use the transformer stage by
using stage variables you can use the logic like check the
first record then check the second record if both are equal
send the output to o/p1 or else send to o/p2....

I hope i made u understand the logic

Is This Answer Correct ?    2 Yes 11 No

i/p o/p1 o/p2 1 1 4 1 ..

Answer / srinivas

first sort the data,
then
take two stage variable
if (sv1=sv2) then ds.link1 else ds.link2

Is This Answer Correct ?    1 Yes 13 No

Post New Answer

More Data Stage Interview Questions

how does work server jobs?

1 Answers  


What is the difference between orabulk and bcp stages?

0 Answers  


I have load a Dataset in UAT with 2 Node configuration, imported the job into PROD environment which is 4 node configuration and using this DataSet as SRC to other job. will the job run fine or give any errors? If job runs fine, on how many nodes? 2 nodes or 4 nodes?

2 Answers   TCS,


What are the processing stages?

0 Answers  


what is the difference between INROWNUM AND OUTROWNUM IN DATASTAGE SERVER EDITION?

2 Answers  






What is container and then types?

1 Answers  


Drop duplicate records ... SOURCE LIKE .......... ID flag1 flag2 100 N Y 100 N N 100 Y N 101 Y Y 101 N Y 102 Y N 103 N N 104 Y Y 105 N N 106 N Y 102 N Y 105 Y Y in above file if any id having both the flags as "N" then that corresponding id records should be dropped, in above case o/p should be as ID flag1 flag2 101 Y Y 101 N Y 102 Y N 102 N Y 104 Y Y 106 N Y Steps to do : 1) Identified the id’s that got duplicated (both the flag values having vales “N”) 2) Look up with these id’s to existing id’s to drop .

2 Answers  


i have the source from Uk,north america how can i pass the data two tables based on the locations

2 Answers  


what is datastage job Monitoring

6 Answers   CTS,


WHAT ARE THE COMMON ERRORS IN DATA STAGE?

6 Answers   IBM, ME,


Hi This is Vijay, How can your remove the duplicates in sequential File?

15 Answers   HCL, Scope International,


Demonstrate experience in maintaining quality process standards?

0 Answers   iGate,


Categories