I have a table in postgresql which has duplicate numbers in a column. I am using Tpostgresqlinput and a query in this as :
select number , count(1) from abc.xyz having count(1)>1 group by number
After this component, I am using tFlowToIterate and then Tjavaflex. In tJavaflex , I am using
Startcode as :
int count = 0; count++;
Maincode as :
if (count>1)
("row1.serial_number",row1.serial_number)
System.out.println(row1.serial_number);
else
System.out.println("Duplicates are not found");
But I am getting the output with the else part as Duplicates are not found.
How do I find the count and name of those serial numbers if it is more than 0 ?
Ideally , the serial numbers should be unique but then there are duplicate serial numbers in the data.So I want to find the duplicate serial number and its count only if it is greater than 1 as an output.
Expected output should be : if there are duplicates ie if the count of serial number is more than 1 then it should send a mail notification to the user that those serial numbers have the count more than 1 ie the serial number and the count no.
In your start code, you init count as 0 and increment by one, which leads to count = 1. This value never changes and therefore you always get the else part of your if.
What you actually want to do is use the count from your input. To accomplish this, use a tJavaRow with:
if(input_row.count > 1)
System.out.println(input_row.serial_number);
else
System.out.println("Duplicates are not found");