SELECT count(*)
FROM users u
WHERE
u.id IN ((
SELECT o.user_id
FROM orders o
WHERE
o.date < '2016-01-01' AND
o.shop_id = 1 AND
o.user_id NOT IN (SELECT user_id FROM orders WHERE shop_id <> 1 AND date < '2016-01-01')
) INTERSECT (
SELECT o.user_id
FROM orders o
WHERE o.date >= '2016-01-01' AND o.shop_id <> 1
));