In MSSQL, my_table table has three columns (as shown below). Serial_Number is the grouping field; Id and Last_update_date contain detail data, and there are duplicate values in the last field.
We need to add a computed column named Flag. The rule is like this: Group rows by Serial_Number and record Flag value as "Y" for each record in this group if there are duplicate Last_update_date values; otherwise record Flag value as "N".
group()function groups rows without aggregation; @u option retains the original order of the records for the result. groups() function performs grouping and aggregation. ~ represents the current group/member; run()function modifies records in order. pselect() returns positions of members meeting the specified condition.
Top comments (1)
SPL open source address:github.com/SPLWare/esProc/stargazers