Question

Sub Query Error (

  • 27 August 2021
  • 0 replies
  • 17 views

Hi Team,

I am trying to develop a query in SQL Runner as below and it gives me error. I want to compare two datetime field. After running the query i am getting error "SQL compilation error: Unsupported subquery type cannot be evaluated".

I am bit new with SQL Runner(snowflake). I want to know how can i compare two datetime field?

Below is the code  for your reference. In this code when i compare " to_timestamp(tq1."JSON":"EndTime") < to_timestamp(tq."JSON":"EndTime")" it gives me above error.

select  tq.Tid as "Tid",
case when (tq."JSON":"PType"::string) IS NOT NULL THEN (tq."JSON":"PType" ::string)
    else  (Select top 1 (tq1."JSON":"PType"::string)
    from xTable   AS tq1
    where tq1.RId is not null
    and   to_timestamp(tq1."JSON":"EndTime") < to_timestamp(tq."JSON":"EndTime")
    order by 1 desc
    )
    end  as "PType"
from xTable  AS tq
where tq.Tid='32194121'

Thanks


This topic has been closed for comments