0

我在 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)]
4

0 回答 0