To begin with, I have a query that works in SSMS but not in DNN. The issue is that my query uses an implicit conversion from char to int and back to char which the DNN module can't handle. I am needing to reformulate it a bit. Needing to add some code to the c3 and c4 segments that cast/convert the periodyear field to int and then back to char. Further below is the code that I have constructed in hopes of doing this but when I place it in C3, I get an error about " [Incorrect syntax near 'CAST', expected 'AS'] ". I am probably incorrect but assuming that the last piece of code would go in C3 after the second case when statement and need where in front of it.
So, my first question is where (if at all) in the C3 section do I put this cast function (or some other convert statement). Am I wrong in thinking that it would need to go in both c3 and c4?
WITH c1 AS (SELECT e.stfips, e.areatype, e.area, e. periodyear, e.period, e.seriescode, e.empces FROM ces as e WHERE e.periodtype='03' And e.supprecord='0' and e.periodyear=
Order by periodyear desc, period desc)
(Select Distinct c1.periodyear, c1.period
(Case When c2.period='01' Then (c2.period + 11) Else (c2.period-1) END) As
(Case When c2.period='01' Then (c2.periodyear -1) Else (c2.periodyear) END) As
(Select c.stfips, c.areatype, c.area, c.periodyear, c.period, c.seriescode, c.empces
From ces as c, c2
Where c.period = c2.period
And c.periodyear = (c2.periodyear-1)
And c.periodyear = ( cast ( cast(c2.periodyear as int) -1 ) as char(10) )