--------------------------------------------------------
--  DDL for View OSEARCH_MIGRATETELEMETRY_MIGVAL_ERRORS_VW
--------------------------------------------------------

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "OTHQ_OWN"."OSEARCH_MIGRATETELEMETRY_MIGVAL_ERRORS_VW" ("ROW_NUMBER", "DURATIONINMINUTES", "DOC_COUNT", "INDEX_", "DBINSTANCE", "DURATIONINSECONDS", "MIGRATIONTASKID", "MIGRATEFILE", "CONTROLSTATE", "NETSUITEPRODUCT", "TIMESTAMP", "MIGRATEVERSION", "DBID", "MIGRATECONTROLFILE", "CONTROLSECTION", "STARTTIME", "MOLECULE", "REGION", "EXCEPTIONMESSAGE", "METADATA_REGION", "METADATA_DOWNLOADED_TIMESTAMP_UTC", "ENDTIME", "EXCEPTIONCLASS", "DBENDSIZEINGB", "EXCEPTIONMESSAGE_HASH", "MIGRATESTATE", "METADATA_ORA_CODES", "METADATA_ANALYZED_TEXT") DEFAULT COLLATION "USING_NLS_COMP"  AS 
  SELECT
    "ROW_NUMBER","DURATIONINMINUTES","DOC_COUNT","INDEX_","DBINSTANCE","DURATIONINSECONDS","MIGRATIONTASKID","MIGRATEFILE","CONTROLSTATE","NETSUITEPRODUCT","TIMESTAMP","MIGRATEVERSION","DBID","MIGRATECONTROLFILE","CONTROLSECTION","STARTTIME","MOLECULE","REGION","EXCEPTIONMESSAGE","METADATA_REGION","METADATA_DOWNLOADED_TIMESTAMP_UTC","ENDTIME","EXCEPTIONCLASS","DBENDSIZEINGB","EXCEPTIONMESSAGE_HASH","MIGRATESTATE","METADATA_ORA_CODES","METADATA_ANALYZED_TEXT"
FROM
    (
        SELECT
            ROW_NUMBER() OVER(PARTITION BY dbid, migrateversion, migrationtaskid, migratefile, exceptionmessage_hash ORDER BY TIMESTAMP DESC) AS row_number,
            durationinseconds / 60 AS durationinminutes,
            e.*
        FROM
            src_osearch_migratetelemetry_migval_tb e
        WHERE
            exceptionmessage_hash IS NOT NULL AND exceptionmessage_hash <> '__missing__'
    )
WHERE
    row_number = 1
;
