I want to use SNumber
in the second part of CASE
expression but not sure how to use it?
(case when(PE.EDateTime is not NULL and cast(PE.EDateTime as time) < '12:30') then cast(format(PE.EDateTime,'yyyyMMddhhmm') as varchar(50))+'AM' when (PE.ADate is not NULL and cast(PE.ADate as time) < '12:30') then cast(format(PE.ADate,'yyyyMMddhhmm') as varchar(50))+'AM' when (PE.EDateTime is not NULL and cast(PE.EDateTime as time) >= '12:30') THEN cast(format(PE.EDateTime,'yyyyMMddhhmm') as varchar(50))+'PM' when (PE.ADate is not NULL and cast(PE.ADate as time) > '12:30') then cast(format(PE.ADate,'yyyyMMddhhmm') as varchar(50))+'PM' else null end) as SNumber
I want to use SNumber
here below in the same query but I am not able to use this as this all belongs to one query. Is there any way to use the above in below CASE
? I want to use something like below.
case when (SNumber contains 'AM') then 'AM' when SNumber contains 'PM') then 'PM' else null end as Session,
https://stackoverflow.com/questions/67363054/how-to-use-one-data-field-into-another-case-expression-in-the-same-query May 03, 2021 at 11:05AM
没有评论:
发表评论