Ingres sql - 'then'语法错误,正确的语法是:

时间:2016-03-01 00:24:36

标签: sql ingres

我在ingresql中有一些似乎不起作用的代码。我在Postgres中尝试使用相同类型的问题并且运行得很好。现在,当我在ingres中尝试它时,它有很大的问题。

select sum(case when date_part('year', order_dt) = 2015 then invoice_amt else 0 end) last_yr
    ,sum(case when date_part('year', order_dt) = 2016 then invoice_amt else 0 end) sales
    ,s.group_cd
    ,sum(s.on_hand) on_hand
from invoicehist ih
left join invitemhist iih 
on iih.order_no = ih.order_no
left join stock s
on s.stock_no = iih.stock_no
where date_part('year', order_dt) >= 2015 and date_part('month', order_dt) = 1
group by s.group_cd

我得到的错误是:

Syntax error on 'then', the correct syntax is:  SELECT [ALL|DISTINCT] target_list FROM table(s) [WHERE serch_cond]
[GROUP BY col(s)] [HAVING] search_cond]
[UNION subselect] [ORDER BY col(s)]

0 个答案:

没有答案