here is how you can do it :
select u.id , u.email , oo.category,oo.created_at
from users u
cross apply ( select TOP 1 *
from orders
where o.user_id = u.id
order by created_at asc
) oo
where u.created between '1-1-2020' and '30-12-2020'
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…