I believe this will be dependent on the database optimizer itself and how it handles the query when no order by is specified.
I ran into a similar issue a couple of years back, where an automation script suddenly behaved differently in two environments. We were using a relationship with 1-to-many cardinality (specifically it was 1:2).
It used to consistently return the same row in both our test and production environments, before all of a sudden the production environment started returning the "other" row. Did not investigate to pinpoint the exact reason as of why - just enough to realize what was happening and how to fix it. My memory of the specifics is a bit blurry, but I think we got the "other" row because the database server was upgraded and the optimizer decided to do things differently..
In any case, the below link explains this in much greater detail than I am able to:
https://stackoverflow.com/questions/26236352/default-row-order-in-select-query-sql-server-2008-vs-sql-2012And you should absolutely look into creating a new relationship that specifies which exact classancestor record you want; for example by adding a min/max function to the WHERE-clause. I've done that in the past to get a specific description for a status change, e.g. finding the second-to-last status change, or being 100% sure that I am getting the newest work log record for an SR to add to a communication template.
------------------------------
Henrik Christiansen
------------------------------
Original Message:
Sent: Wed March 03, 2021 12:32 AM
From: User1971
Subject: Field based on relationship: What if relationship is 1:M?
MAM 7.6.1.2:
I have a custom field in Classifications that is based on a Maximo relationship:



That relationship can return multiple records:
select *from maximo.classancestorwhere classstructureid = '32770'

Question:
How does Maximo handle the 1:M scenario? (aka: one classification record is related to many classancestor records)
- It seems like Maximo only retrieves the record with the maximum HIERARCHYLEVELS value. But I don't understand why Maximo is behaving that way / if it will always behave that way.
- Is it just grabbing the last record that was inserted to the database table?
Thanks.
#Maximo
#AssetandFacilitiesManagement