Find maximum and minimum time difference

Hi All,

Is there a way to find out the maximum and minimum time difference for 3rd column in the query below; whenever I am trying to order it by 3rd column I am getting below error

Cannot order by non-grouped column

Query :

POST /_sql?format=txt
{
  "query": "SELECT SERVICE_NAME,CHANNEL_NAME, CASE WHEN TIME_3 <> 'T' and TIME_1 <> 'T'  THEN DATEDIFF('seconds', CAST(TIME_1 AS DATETIME), CAST(TIME_3 AS DATETIME)) ELSE 0 END  AS DiffInSeconds   FROM \"Tem_visualization*\" WHERE \"@timestamp\" >= NOW() -  INTERVAL 10 Minutes  GROUP BY SERVICE_NAME, CHANNEL_NAME, TIME_3, TIME_1 order by 3 desc"
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.