How use "Case....when....end" in a Query by NODBC

colac_m
colac_m Member Posts: 5
Hi,
I want to use the sentence "case...when...end" in a select with NODBC and I have a Sintax error.
The System is Navision 4.0 sp2 with Database Native.

Example:
select "Ship-to Country Code",
case when month("Posting Date") = 1 then sum(Amount) end as Jan,
case when month("Posting Date") = 2 then sum(Amount) end as Feb
from "Sales Invoice Header"
where year("Posting Date") = 2009

Anyone know how use the sentence "case"?

Thanks in advance.

Comments

  • MBerger
    MBerger Member Posts: 413
    my T-SQL is a bit rusty, but isn't the syntax
    "case when <condition-1> then <result-1> when <condition-2> then <result-2> .... when <condition-n> then <result-n> end"
    
  • colac_m
    colac_m Member Posts: 5
    In Sql Server is ok, but I use Nodbc in Navision Native from .NET and have sintax error.