Henry Olive 5 Posted July 7, 2021 (edited) I wish everyone a healthy day Interbase SQL I'm getting expression evaluation not supported err.msg. with below SQL If I remove (Case.........end) which is 2.Line in SQL command, The Sql works What is wrong ? SELECT O.DELVTYPE, SUM(OD.REMAINQTY) QTY, (Case When O.DELVTYPE ='Sea' then O.DELVDATE + 45 else O.DELVDATE + 15 end) as DELVDATE FROM ORDETAIL OD JOIN ORDERS O ON O.RNO=OD.RNO WHERE OD.ITEMNO = 'ABX22' GROUP BY O.DELVTYPE, O.DELVDATE HAVING SUM(OD.REMAINQTY) > 0 Thank You Edited July 7, 2021 by Henry Olive Share this post Link to post
Frickler 11 Posted July 7, 2021 What if you remove the parentheses around the case statement? Share this post Link to post
Henry Olive 5 Posted July 7, 2021 (edited) Thank You Frickler, If i remove parentheses nothing changes , still get the same err.msg. Edited July 7, 2021 by Henry Olive Share this post Link to post
Frickler 11 Posted July 7, 2021 It's possible that Interbase supports only "simple case", that is case foo when 1 then 'one' when 2 then 'two' else 'many' end Share this post Link to post
Henry Olive 5 Posted July 7, 2021 Thank You again Frickler, I tried your last suggestion ( simple case) but still getting the same err. msg. Share this post Link to post
david_navigator 12 Posted July 7, 2021 Do you need to cast the results to be the same type of the field ? Share this post Link to post
corneliusdavid 214 Posted July 7, 2021 Yes, IB uses "simple" case. Try this: SELECT O.DELVTYPE, SUM(OD.REMAINQTY) QTY, (Case O.DELVTYPE When 'Sea' then O.DELVDATE + 45 else O.DELVDATE + 15 end) as DELVDATE FROM ORDETAIL OD JOIN ORDERS O ON O.RNO=OD.RNO WHERE OD.ITEMNO = 'ABX22' GROUP BY O.DELVTYPE, O.DELVDATE HAVING SUM(OD.REMAINQTY) > 0 Share this post Link to post
Lajos Juhász 293 Posted July 7, 2021 Most probably the problem is the group by part. You've there O.Delvdate that is not in the select list. Interbase 2017 Update 1 (http://docwiki.embarcadero.com/InterBase/2020/en/Enhancements_to_GROUP_BY_and_ORDER_BY) introduced the extended syntax. If you're using a version that support you can write: SELECT O.DELVTYPE, SUM(OD.REMAINQTY) QTY, (Case O.DELVTYPE When 'Sea' then O.DELVDATE + 45 else O.DELVDATE + 15 end) as DELVDATE FROM ORDETAIL OD JOIN ORDERS O ON O.RNO=OD.RNO WHERE OD.ITEMNO = 'ABX22' GROUP BY O.DELVTYPE, 3 HAVING SUM(OD.REMAINQTY) > 0 Share this post Link to post
Henry Olive 5 Posted July 9, 2021 Thank you so much David, CorneliusDavid, Lajos Share this post Link to post