1
0 Comments

How to Set Duplicate Content in a Dataset to Null with esProc

The first two fields of a certain database table may have duplicate values, such as the first three records below.
source table

Now we need to change all duplicate values to null. In other words, after grouping by the first two fields (equivalent to grouping by one of the fields), only the first record in the group remains unchanged, and the first two fields of other records are changed to null.

The calculation result is as follows:
expected results

After SQL grouping, it must aggregate immediately, and the grouped subsets cannot be kept for further calculation. SQL also does not have natural row numbers within the group, making the code difficult to write.

esProc provides a rich set of calculation functions that can keep grouped subsets for further calculation, with natural row numbers, including row numbers within the group 👉🏻: TryDEMO.
esProc SPL code script

A1: Load data.

A2: Group by the first field using the group function, but do not aggregate.

pic 1
Each group is a set that can be expanded by clicking, as shown in the first two groups.

pic 2
A3: Use the run function to modify the data of each group. When the member’s index in the group is greater than 1, change the first two fields to null. ~ represents the current group, and # represents the sequence number within the group.

pic 3
A4: Merge the groups.

pic 4
The step-by-step code above is beneficial for learning and debugging. Once proficient, A2-A4 can be combined into one statement:

=A1.group(Column_A).run(~.(if(#!=1,Column_A=Column_B=null))).conj()

esProc SPL FREE Download – Free Trial Available, Download Now!

posted to Icon for group Developers
Developers
on May 13, 2025
Trending on Indie Hackers
Your SaaS Isn’t Failing — Your Copy Is. User Avatar 61 comments Build AI Agents & SaaS Apps Visually : Powered by Simplita ai User Avatar 22 comments The Future of Automation: Why Agents + Frontend Matter More Than Workflow Automation User Avatar 21 comments No Install, No Cost, Just Code User Avatar 20 comments AI Turned My $0 Idea into $10K/Month in 45 Days – No Code, Just This One Trick User Avatar 13 comments For years, I was terrible at estimating projects. Here’s what changed. User Avatar 11 comments