Transpose Multiple Columns to Row, find what data are changes, maintain old value if no changesFetch the row which has the Max value for a columnSQL to find the number of distinct values in a columnHow can I SELECT rows with MAX(Column value), DISTINCT by another column in SQL?Find rows that have the same value on a column in MySQLSQL select only rows with max value on a columnFinding rows with same values in multiple columnsTransposing data into multiple columnsSimple way to transpose columns and rows in Sql?What is the safest practical way to deal with non-required MS Access text fields in queries?Transpose 2 columns multiple rows to 1 rows multiple columns
Today is the Center
What's the output of a record needle playing an out-of-speed record
Find the result of this dual key cipher
strTok function (thread safe, supports empty tokens, doesn't change string)
Why is consensus so controversial in Britain?
What would happen to a modern skyscraper if it rains micro blackholes?
Important Resources for Dark Age Civilizations?
How can I prevent hyper evolved versions of regular creatures from wiping out their cousins?
Accidentally leaked the solution to an assignment, what to do now? (I'm the prof)
Approximately how much travel time was saved by the opening of the Suez Canal in 1869?
Why are electrically insulating heatsinks so rare? Is it just cost?
When a company launches a new product do they "come out" with a new product or do they "come up" with a new product?
Can a vampire attack twice with their claws using Multiattack?
How does quantile regression compare to logistic regression with the variable split at the quantile?
Can you really stack all of this on an Opportunity Attack?
Why "Having chlorophyll without photosynthesis is actually very dangerous" and "like living with a bomb"?
Was any UN Security Council vote triple-vetoed?
Can I make popcorn with any corn?
Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?
Are the number of citations and number of published articles the most important criteria for a tenure promotion?
How can I make my BBEG immortal short of making them a Lich or Vampire?
RSA: Danger of using p to create q
Maximum likelihood parameters deviate from posterior distributions
How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?
Transpose Multiple Columns to Row, find what data are changes, maintain old value if no changes
Fetch the row which has the Max value for a columnSQL to find the number of distinct values in a columnHow can I SELECT rows with MAX(Column value), DISTINCT by another column in SQL?Find rows that have the same value on a column in MySQLSQL select only rows with max value on a columnFinding rows with same values in multiple columnsTransposing data into multiple columnsSimple way to transpose columns and rows in Sql?What is the safest practical way to deal with non-required MS Access text fields in queries?Transpose 2 columns multiple rows to 1 rows multiple columns
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
OriData
+------------+-------------------+-------+--------+-------------+----------+------------+---------------+------------+--------------+
| Ori_Date | Resubmission_Date | SeqNo | IDNO | PX_Name_OLD | Name_NEW | NameReason | PX_Gender_OLD | Gender_New | GenderReason |
+------------+-------------------+-------+--------+-------------+----------+------------+---------------+------------+--------------+
| 2019-01-01 | 2019-01-03 | A123 | ID123 | OldName | NewName | Valid | L | P | Valid |
| 2019-02-01 | 2019-02-03 | AB456 | A26589 | Captain | IronMan | Valid | L | | |
+------------+-------------------+-------+--------+-------------+----------+------------+---------------+------------+--------------+
Result I Want
+------------+-------------------+-------+--------+---------+------------+----------+---------+------------+--------+--------------+
| Ori_Date | Resubmission_Date | SeqNo | IDNo | Col_Chg | From_Value | To_Value | Name | NameReason | Gender | GenderReason |
+------------+-------------------+-------+--------+---------+------------+----------+---------+------------+--------+--------------+
| 2019-01-01 | 2019-01-03 | A123 | ID123 | Name | OldName | NewName | NewName | Valid | P | NULL |
| 2019-01-01 | 2019-01-03 | A123 | ID123 | Gender | L | P | NewName | NULL | P | Valid |
| 2019-02-01 | 2019-02-03 | AB456 | A26589 | Name | Captain | IronMan | IronMan | Valid | L | NULL |
+------------+-------------------+-------+--------+---------+------------+----------+---------+------------+--------+--------------+
Query that I wrote:
select Seqno, IDNo, ColName, Vals
from
(
select
isnull(cast(reqid as nvarchar(255)), '') AS Seqno,
isnull(cast(Name collate database_default as nvarchar(255)), '') as Name,
isnull(cast(IDNo collate database_default as nvarchar(255)), '') as IDNo,
isnull(cast(Gender collate database_default as nvarchar(255)), '') as Gender
from #A
where NameReason IS NOT NULL or GenderReason IS NOT NULL
) unpivot_table
unpivot
(
vals for colname in (Name, Gender
)
) unpivot_handle
Whenever there is a value in NameReason/GenderReason, then it will triggered the changes thats why in query i put NameReason or GenderReason IS NOT NULL.
PX = Table1-old value , xx_New = Table 2-new value (if any-but definitely there is an update for some of columns), I joined them together and insert to table #A.
Name column, if there is changes, will take New_Name column.
Gender column, if there no changes, will take PX_Gender aka old value.
With my query, I'm not able to get From_Value, To_Value, and other columns. Any idea how to get the result I want?
Note: Im dealing with 10mil records, 20+ cols, I cannot hardcode it.
sql sql-server
add a comment |
OriData
+------------+-------------------+-------+--------+-------------+----------+------------+---------------+------------+--------------+
| Ori_Date | Resubmission_Date | SeqNo | IDNO | PX_Name_OLD | Name_NEW | NameReason | PX_Gender_OLD | Gender_New | GenderReason |
+------------+-------------------+-------+--------+-------------+----------+------------+---------------+------------+--------------+
| 2019-01-01 | 2019-01-03 | A123 | ID123 | OldName | NewName | Valid | L | P | Valid |
| 2019-02-01 | 2019-02-03 | AB456 | A26589 | Captain | IronMan | Valid | L | | |
+------------+-------------------+-------+--------+-------------+----------+------------+---------------+------------+--------------+
Result I Want
+------------+-------------------+-------+--------+---------+------------+----------+---------+------------+--------+--------------+
| Ori_Date | Resubmission_Date | SeqNo | IDNo | Col_Chg | From_Value | To_Value | Name | NameReason | Gender | GenderReason |
+------------+-------------------+-------+--------+---------+------------+----------+---------+------------+--------+--------------+
| 2019-01-01 | 2019-01-03 | A123 | ID123 | Name | OldName | NewName | NewName | Valid | P | NULL |
| 2019-01-01 | 2019-01-03 | A123 | ID123 | Gender | L | P | NewName | NULL | P | Valid |
| 2019-02-01 | 2019-02-03 | AB456 | A26589 | Name | Captain | IronMan | IronMan | Valid | L | NULL |
+------------+-------------------+-------+--------+---------+------------+----------+---------+------------+--------+--------------+
Query that I wrote:
select Seqno, IDNo, ColName, Vals
from
(
select
isnull(cast(reqid as nvarchar(255)), '') AS Seqno,
isnull(cast(Name collate database_default as nvarchar(255)), '') as Name,
isnull(cast(IDNo collate database_default as nvarchar(255)), '') as IDNo,
isnull(cast(Gender collate database_default as nvarchar(255)), '') as Gender
from #A
where NameReason IS NOT NULL or GenderReason IS NOT NULL
) unpivot_table
unpivot
(
vals for colname in (Name, Gender
)
) unpivot_handle
Whenever there is a value in NameReason/GenderReason, then it will triggered the changes thats why in query i put NameReason or GenderReason IS NOT NULL.
PX = Table1-old value , xx_New = Table 2-new value (if any-but definitely there is an update for some of columns), I joined them together and insert to table #A.
Name column, if there is changes, will take New_Name column.
Gender column, if there no changes, will take PX_Gender aka old value.
With my query, I'm not able to get From_Value, To_Value, and other columns. Any idea how to get the result I want?
Note: Im dealing with 10mil records, 20+ cols, I cannot hardcode it.
sql sql-server
I don't understand your desired results. Why is gender both in columns and in an additional row?
– Gordon Linoff
Mar 9 at 4:08
@GordonLinoff if there is changes show the new result in all rows (under same idno). as you can see from idno:A26589, there is no changes for gender, so desired result is showing old value instead.
– user3542587
Mar 9 at 13:02
add a comment |
OriData
+------------+-------------------+-------+--------+-------------+----------+------------+---------------+------------+--------------+
| Ori_Date | Resubmission_Date | SeqNo | IDNO | PX_Name_OLD | Name_NEW | NameReason | PX_Gender_OLD | Gender_New | GenderReason |
+------------+-------------------+-------+--------+-------------+----------+------------+---------------+------------+--------------+
| 2019-01-01 | 2019-01-03 | A123 | ID123 | OldName | NewName | Valid | L | P | Valid |
| 2019-02-01 | 2019-02-03 | AB456 | A26589 | Captain | IronMan | Valid | L | | |
+------------+-------------------+-------+--------+-------------+----------+------------+---------------+------------+--------------+
Result I Want
+------------+-------------------+-------+--------+---------+------------+----------+---------+------------+--------+--------------+
| Ori_Date | Resubmission_Date | SeqNo | IDNo | Col_Chg | From_Value | To_Value | Name | NameReason | Gender | GenderReason |
+------------+-------------------+-------+--------+---------+------------+----------+---------+------------+--------+--------------+
| 2019-01-01 | 2019-01-03 | A123 | ID123 | Name | OldName | NewName | NewName | Valid | P | NULL |
| 2019-01-01 | 2019-01-03 | A123 | ID123 | Gender | L | P | NewName | NULL | P | Valid |
| 2019-02-01 | 2019-02-03 | AB456 | A26589 | Name | Captain | IronMan | IronMan | Valid | L | NULL |
+------------+-------------------+-------+--------+---------+------------+----------+---------+------------+--------+--------------+
Query that I wrote:
select Seqno, IDNo, ColName, Vals
from
(
select
isnull(cast(reqid as nvarchar(255)), '') AS Seqno,
isnull(cast(Name collate database_default as nvarchar(255)), '') as Name,
isnull(cast(IDNo collate database_default as nvarchar(255)), '') as IDNo,
isnull(cast(Gender collate database_default as nvarchar(255)), '') as Gender
from #A
where NameReason IS NOT NULL or GenderReason IS NOT NULL
) unpivot_table
unpivot
(
vals for colname in (Name, Gender
)
) unpivot_handle
Whenever there is a value in NameReason/GenderReason, then it will triggered the changes thats why in query i put NameReason or GenderReason IS NOT NULL.
PX = Table1-old value , xx_New = Table 2-new value (if any-but definitely there is an update for some of columns), I joined them together and insert to table #A.
Name column, if there is changes, will take New_Name column.
Gender column, if there no changes, will take PX_Gender aka old value.
With my query, I'm not able to get From_Value, To_Value, and other columns. Any idea how to get the result I want?
Note: Im dealing with 10mil records, 20+ cols, I cannot hardcode it.
sql sql-server
OriData
+------------+-------------------+-------+--------+-------------+----------+------------+---------------+------------+--------------+
| Ori_Date | Resubmission_Date | SeqNo | IDNO | PX_Name_OLD | Name_NEW | NameReason | PX_Gender_OLD | Gender_New | GenderReason |
+------------+-------------------+-------+--------+-------------+----------+------------+---------------+------------+--------------+
| 2019-01-01 | 2019-01-03 | A123 | ID123 | OldName | NewName | Valid | L | P | Valid |
| 2019-02-01 | 2019-02-03 | AB456 | A26589 | Captain | IronMan | Valid | L | | |
+------------+-------------------+-------+--------+-------------+----------+------------+---------------+------------+--------------+
Result I Want
+------------+-------------------+-------+--------+---------+------------+----------+---------+------------+--------+--------------+
| Ori_Date | Resubmission_Date | SeqNo | IDNo | Col_Chg | From_Value | To_Value | Name | NameReason | Gender | GenderReason |
+------------+-------------------+-------+--------+---------+------------+----------+---------+------------+--------+--------------+
| 2019-01-01 | 2019-01-03 | A123 | ID123 | Name | OldName | NewName | NewName | Valid | P | NULL |
| 2019-01-01 | 2019-01-03 | A123 | ID123 | Gender | L | P | NewName | NULL | P | Valid |
| 2019-02-01 | 2019-02-03 | AB456 | A26589 | Name | Captain | IronMan | IronMan | Valid | L | NULL |
+------------+-------------------+-------+--------+---------+------------+----------+---------+------------+--------+--------------+
Query that I wrote:
select Seqno, IDNo, ColName, Vals
from
(
select
isnull(cast(reqid as nvarchar(255)), '') AS Seqno,
isnull(cast(Name collate database_default as nvarchar(255)), '') as Name,
isnull(cast(IDNo collate database_default as nvarchar(255)), '') as IDNo,
isnull(cast(Gender collate database_default as nvarchar(255)), '') as Gender
from #A
where NameReason IS NOT NULL or GenderReason IS NOT NULL
) unpivot_table
unpivot
(
vals for colname in (Name, Gender
)
) unpivot_handle
Whenever there is a value in NameReason/GenderReason, then it will triggered the changes thats why in query i put NameReason or GenderReason IS NOT NULL.
PX = Table1-old value , xx_New = Table 2-new value (if any-but definitely there is an update for some of columns), I joined them together and insert to table #A.
Name column, if there is changes, will take New_Name column.
Gender column, if there no changes, will take PX_Gender aka old value.
With my query, I'm not able to get From_Value, To_Value, and other columns. Any idea how to get the result I want?
Note: Im dealing with 10mil records, 20+ cols, I cannot hardcode it.
sql sql-server
sql sql-server
edited Mar 9 at 1:25
user3542587
asked Mar 9 at 1:17
user3542587user3542587
237
237
I don't understand your desired results. Why is gender both in columns and in an additional row?
– Gordon Linoff
Mar 9 at 4:08
@GordonLinoff if there is changes show the new result in all rows (under same idno). as you can see from idno:A26589, there is no changes for gender, so desired result is showing old value instead.
– user3542587
Mar 9 at 13:02
add a comment |
I don't understand your desired results. Why is gender both in columns and in an additional row?
– Gordon Linoff
Mar 9 at 4:08
@GordonLinoff if there is changes show the new result in all rows (under same idno). as you can see from idno:A26589, there is no changes for gender, so desired result is showing old value instead.
– user3542587
Mar 9 at 13:02
I don't understand your desired results. Why is gender both in columns and in an additional row?
– Gordon Linoff
Mar 9 at 4:08
I don't understand your desired results. Why is gender both in columns and in an additional row?
– Gordon Linoff
Mar 9 at 4:08
@GordonLinoff if there is changes show the new result in all rows (under same idno). as you can see from idno:A26589, there is no changes for gender, so desired result is showing old value instead.
– user3542587
Mar 9 at 13:02
@GordonLinoff if there is changes show the new result in all rows (under same idno). as you can see from idno:A26589, there is no changes for gender, so desired result is showing old value instead.
– user3542587
Mar 9 at 13:02
add a comment |
1 Answer
1
active
oldest
votes
I think you want this:
select a.Ori_Date, a.Resubmission_Date, a.SeqNo, a.IDNO,
v.*
from #a a cross apply
(values ('Name', PX_Name_OLD, Name_NEW, NameReason),
('Gender', PX_Gender_OLD, Gender_New, GenderReason)
) v(Col_Chg, From_Value, To_Value, Reason)
where reason is not null;
Note: This does not include all the columns that you have. The additional gender columns seem redundant.
the result almost there but now i got new problem arise. its show all columns that even without changes. i tried playing around with 'where condition' but still no luck. because i only keep track that if 'reason' column is not null, meaning definitely the column got changes. even if FX_Occupation_old = value: A, in Occupation_new = value: B, but occupationReason is null, then no changes.
– user3542587
Mar 9 at 13:07
@user3542587 . . . That is based on thewhere
clause. Maybe it should be on the reason instead of the values.
– Gordon Linoff
Mar 9 at 13:30
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55073061%2ftranspose-multiple-columns-to-row-find-what-data-are-changes-maintain-old-valu%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I think you want this:
select a.Ori_Date, a.Resubmission_Date, a.SeqNo, a.IDNO,
v.*
from #a a cross apply
(values ('Name', PX_Name_OLD, Name_NEW, NameReason),
('Gender', PX_Gender_OLD, Gender_New, GenderReason)
) v(Col_Chg, From_Value, To_Value, Reason)
where reason is not null;
Note: This does not include all the columns that you have. The additional gender columns seem redundant.
the result almost there but now i got new problem arise. its show all columns that even without changes. i tried playing around with 'where condition' but still no luck. because i only keep track that if 'reason' column is not null, meaning definitely the column got changes. even if FX_Occupation_old = value: A, in Occupation_new = value: B, but occupationReason is null, then no changes.
– user3542587
Mar 9 at 13:07
@user3542587 . . . That is based on thewhere
clause. Maybe it should be on the reason instead of the values.
– Gordon Linoff
Mar 9 at 13:30
add a comment |
I think you want this:
select a.Ori_Date, a.Resubmission_Date, a.SeqNo, a.IDNO,
v.*
from #a a cross apply
(values ('Name', PX_Name_OLD, Name_NEW, NameReason),
('Gender', PX_Gender_OLD, Gender_New, GenderReason)
) v(Col_Chg, From_Value, To_Value, Reason)
where reason is not null;
Note: This does not include all the columns that you have. The additional gender columns seem redundant.
the result almost there but now i got new problem arise. its show all columns that even without changes. i tried playing around with 'where condition' but still no luck. because i only keep track that if 'reason' column is not null, meaning definitely the column got changes. even if FX_Occupation_old = value: A, in Occupation_new = value: B, but occupationReason is null, then no changes.
– user3542587
Mar 9 at 13:07
@user3542587 . . . That is based on thewhere
clause. Maybe it should be on the reason instead of the values.
– Gordon Linoff
Mar 9 at 13:30
add a comment |
I think you want this:
select a.Ori_Date, a.Resubmission_Date, a.SeqNo, a.IDNO,
v.*
from #a a cross apply
(values ('Name', PX_Name_OLD, Name_NEW, NameReason),
('Gender', PX_Gender_OLD, Gender_New, GenderReason)
) v(Col_Chg, From_Value, To_Value, Reason)
where reason is not null;
Note: This does not include all the columns that you have. The additional gender columns seem redundant.
I think you want this:
select a.Ori_Date, a.Resubmission_Date, a.SeqNo, a.IDNO,
v.*
from #a a cross apply
(values ('Name', PX_Name_OLD, Name_NEW, NameReason),
('Gender', PX_Gender_OLD, Gender_New, GenderReason)
) v(Col_Chg, From_Value, To_Value, Reason)
where reason is not null;
Note: This does not include all the columns that you have. The additional gender columns seem redundant.
edited Mar 9 at 13:29
answered Mar 9 at 4:08
Gordon LinoffGordon Linoff
794k37318421
794k37318421
the result almost there but now i got new problem arise. its show all columns that even without changes. i tried playing around with 'where condition' but still no luck. because i only keep track that if 'reason' column is not null, meaning definitely the column got changes. even if FX_Occupation_old = value: A, in Occupation_new = value: B, but occupationReason is null, then no changes.
– user3542587
Mar 9 at 13:07
@user3542587 . . . That is based on thewhere
clause. Maybe it should be on the reason instead of the values.
– Gordon Linoff
Mar 9 at 13:30
add a comment |
the result almost there but now i got new problem arise. its show all columns that even without changes. i tried playing around with 'where condition' but still no luck. because i only keep track that if 'reason' column is not null, meaning definitely the column got changes. even if FX_Occupation_old = value: A, in Occupation_new = value: B, but occupationReason is null, then no changes.
– user3542587
Mar 9 at 13:07
@user3542587 . . . That is based on thewhere
clause. Maybe it should be on the reason instead of the values.
– Gordon Linoff
Mar 9 at 13:30
the result almost there but now i got new problem arise. its show all columns that even without changes. i tried playing around with 'where condition' but still no luck. because i only keep track that if 'reason' column is not null, meaning definitely the column got changes. even if FX_Occupation_old = value: A, in Occupation_new = value: B, but occupationReason is null, then no changes.
– user3542587
Mar 9 at 13:07
the result almost there but now i got new problem arise. its show all columns that even without changes. i tried playing around with 'where condition' but still no luck. because i only keep track that if 'reason' column is not null, meaning definitely the column got changes. even if FX_Occupation_old = value: A, in Occupation_new = value: B, but occupationReason is null, then no changes.
– user3542587
Mar 9 at 13:07
@user3542587 . . . That is based on the
where
clause. Maybe it should be on the reason instead of the values.– Gordon Linoff
Mar 9 at 13:30
@user3542587 . . . That is based on the
where
clause. Maybe it should be on the reason instead of the values.– Gordon Linoff
Mar 9 at 13:30
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55073061%2ftranspose-multiple-columns-to-row-find-what-data-are-changes-maintain-old-valu%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I don't understand your desired results. Why is gender both in columns and in an additional row?
– Gordon Linoff
Mar 9 at 4:08
@GordonLinoff if there is changes show the new result in all rows (under same idno). as you can see from idno:A26589, there is no changes for gender, so desired result is showing old value instead.
– user3542587
Mar 9 at 13:02