Třídová akce

Kód:
5
Tělo:
select
   sd.id,  sum(sd2.tamount)
from
  storedocuments sd
  join storedocuments2 sd2 on sd2.parent_id=sd.id
where
  sd.documenttype=:DocumentType and
  sd.docdate$date=:DocDate and
  sd2.quantity<>0 and
  ((coalesce(:BusOrder_ID, '0000000000') <> '0000000000') or
   (coalesce(:BusTransaction_ID, '0000000000') <> '0000000000') or
   (coalesce(:BusProject_ID, '0000000000') <> '0000000000')) and
  ((coalesce(sd2.BusOrder_ID, '0000000000') = coalesce(:BusOrder_ID, '0000000000')) or
   (coalesce(:BusOrder_ID, '0000000000') = '0000000000')) and
  ((coalesce(sd2.BusTransaction_ID, '0000000000') = coalesce(:BusTransaction_ID, '0000000000')) or
   (coalesce(:BusTransaction_ID, '0000000000') = '0000000000')) and
  ((coalesce(sd2.BusProject_ID, '0000000000') = coalesce(:BusProject_ID, '0000000000')) or
   (coalesce(:BusProject_ID, '0000000000') = '0000000000'))
group by
  sd.id

Generated by ABRA Software a.s. 27.10.2021 16:35:32