Разобрать исключение в улье - PullRequest
0 голосов
/ 04 октября 2018

Я построил запрос улья, который объединит 2 таблицы и получит сумму столбцов и, основываясь на этом, написал вложенный оператор case, который выглядит следующим образом:

select purchasing_document, pdoc_litem, po_quantity, po_value,gr_quantity, gr_value, ir_quantity, ir_value, 
case 
when po_quantity != '0' then
case    
when gr_quantity != '0' then
case
when ir_quantity = '0' then 'Invoice qty not posted'
when ir_quantity != '0' and gr_quantity > ir_quantity then 'Invoice qty is partially posted'
when gr_quantity < ir_quantity then 'Invoice qty exceeds GR qty '
else 'Invoice qty is completely posted' end
when gr_quantity = '0' then
case
when ir_quantity != '0' then 'Invoice qty exceeds GR qty where GR qty = 0'
else 'Both GR and Invoice qty not posted at all' end
else '' end
else 'PO qty not present' end as comment1
from
( select  a.purchasing_document, a.pdoc_litem ,
               sum(b.re_quantity)    ir_quantity,
               min(b.re_quantity)    min_ir_quantity,
               sum(b.re_value)       ir_value,
               sum(a.we_quantity)    gr_quantity,
               min(a.we_quantity)    min_gr_quantity,
               sum(a.we_value)       gr_value,
               min(a.Po_quantity) po_quantity,
               min(a.PO_value)    po_value
       from grir_data_we_only a join grir_data_re_only b ON (a.pdoc_litem = b.pdoc_litem)
       group by purchasing_document, pdoc_litem 
       )s order by     purchasing_document, pdoc_litem limit 10;

Но я получаюошибка ниже:

FAILED: ParseException line 5:0 cannot recognize input near 'when' 'gr_quantity' '!=' in expression specification

Можете ли вы помочь в этом?Спасибо !!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...