Наталья
Знаток
(275)
1 год назад
With q As (select V_COLOR, V_ID,
CASE
WHEN SUM(B_VOL) IS NULL
THEN 255
ELSE 255-SUM(B_VOL)
END RemainPaint
from utB right join utV on B_V_ID = V_ID
group by V_COLOR, V_ID)
Select iif(count(*)=3, min(r),0) Qty
from (Select SUM(RemainPaint)/255 r from q
Group by V_color) w
оставшейся краской