-- This is a sample query which illustrates an apparent problem where
-- sorting is not correct for an RM table which is collated by
-- the RMNOCASE collating sequence. The ORDER BY FT.Name statement
-- should sort the query results by the FactTypeTable.Name column,
-- but it fails to do so. Correct results may be obtained by changing
-- the statement to ORDER BY FT.Abbrev or by changing the statement
-- to ORDER BY FT.NAME COLLATE NOCASE. The use of FT.Abbrev works
-- because (for my database) the contents of FactTableType.Name and
-- FactTableType.Abbrev are identical and because FactTableType.Abbrev
-- is not collated by RMNOCASE. The override of RMNOCASE with NOCASE works
-- because the standard NOCASE collation doesn't have whatever is the apparent
-- problem in the RMNOCASE collation.

SELECT FT.FactTypeID, FT.Name, FT. Abbrev, FT.GedcomTag
FROM FactTypeTable AS FT
         JOIN
     EventTable AS E ON FT.FactTypeID = E.EventType
WHERE FT.Name LIKE('%marriage%')
ORDER BY FT.Name;