select
store.id, max(store.Name) as Name
from
posdocuments2 pd2
join stores store on store.id=pd2.store_id
where
pd2.OrderFinished = 'N' and
((pd2.orderkind = 2) and
((pd2.quantity>0) or
(pd2.orderwastequantity>0)))
group by
store.idGenerated by ABRA Software a.s. 27.10.2021 16:34:30