Are you looking for ways to identify duplicate values in a NetSuite saved search?
(NOTE: This uses SQL in Suitescript)
NetSuite Target Using SQL
Please note that this solution will not work directly in NetSuite, but it will give you the desired duplicate rows.
1. Write the following SQL query:
select t.*,
sum(1) over (partition by id1, id2)
from @table t
order by t.id1, t.id2;
2. Replace the `@table` with your actual table name, and `id1` and `id2` with the columns you want to check for duplicates.
This query will give you values greater than 1 on each duplicate row.
Working NetSuite Version
A version that works specifically in NetSuite:
sum/* comment */(1) OVER(PARTITION BY {name})
This solution will also assign a value greater than 1 to any row that is a duplicate.
Here's how this solution works:
1. The `sum(1) over (partition by {partition column(s)})` part of the query sums the value 1 for each row within the specified partition.
2. The partition column(s) should be the columns you consider as defining a duplicate. If you have one column for duplicates, like a user ID, use the syntax mentioned above. If you have multiple columns for duplicates, like first name, last name, and city, use a comma-separated list in the partition.
3. SQL will group the rows by the partition columns and calculate the sum of 1s. In this case, we are summing the value 1 instead of an actual column. So, a value of 1 indicates a unique record, while any higher value indicates a duplicate. You can think of this field as the duplicate count.
By following these instructions, you will be able to highlight duplicate values in a NetSuite saved search effectively.