July 31, 2019 at 3:33 pm
I'm trying to show below if HR = 8 then show 8 till 9 but i am getting a conversation failed error
Select dealer, Created, ServCode, Tran1, Tran2, Tran3, logfile.OpNum, RegNo,agents.Name, datepart(hour , LogFile.Created) AS
,
Case datepart(hour , LogFile.Created) WHEN 8 THEN '8 till 9' ELSE 0 END
July 31, 2019 at 3:44 pm
ELSE '0' END
July 31, 2019 at 3:46 pm
No way, thats amazing thanks very much
July 31, 2019 at 4:21 pm
The CASE expression has two forms. We stole the syntax from the Ada programming language. You are trying to use the form looks like a switch construct in other programming languages, but the other form is probably more appropriate. Remember that being an expression you're going to get back the highest data tape in all of the THEN clauses; that would be your string. This means the else clause will have to be something that can easily be cast to a string or it could be NULL. Also, "creation" is not a valid column name. We need <atttribute>_<attribute property>. Please read the ISO 11179 rules or any book on data modeling
CASE WHEN DATEPART(HOUR, LogFile.creation_timestamp) = 8
THEN '8 till 9'
ELSE NULL END
Please post DDL and follow ANSI/ISO standards when asking for help.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply