无法获得每个ID的唯一Jobid

时间:2019-06-17 18:04:45

标签: case distinct

我有标识符,我正在为每个标识符提取jobId。这些Jobid是重复的。我想为每个标识符获取唯一的Jobid。

      ,DISTINCT(res.jobId)
FROM
(
SELECT em.created_at
      ,em.event_id
      ,em.identifier
      ,em.lbb_diag_type
      ,em.lbb_diag_value
      ,em.model
      ,em.sw_pkg_version
      ,(CASE WHEN NULLIF(JSON_EXTRACT_PATH_TEXT(em.lbb_diag_value,'execution','status',true),'') = 'QUEUED' THEN 'Queued'
                         ELSE NULL END) AS status
      ,(CASE WHEN status = 'Queued' THEN NULLIF(JSON_EXTRACT_PATH_TEXT(em.lbb_diag_value,'execution','jobId',true),'')
                         ELSE NULL END) AS jobId
      ,(CASE WHEN NULLIF(JSON_EXTRACT_PATH_TEXT(em.lbb_diag_value, 'execution', 'jobDocument', 'type', true), '') = 'camera-format' THEN 'CameraFormat' ELSE NULL END) AS type_camera_format
               FROM eld_messages em
               WHERE status = 'Queued'
                 AND em.created_at >= getdate()-30
                 AND em.type = 'lbb_diag' 
                 AND em.lbb_diag_type = 'sra_diag'
                 AND type_camera_format IS NOT NULL
) res

但是我在DISTINCT遇到错误。

0 个答案:

没有答案