Nov 15, 2020 12:50 PM|mgebhard|LINK
The TSQL can be refactored using a basic join rather than a WHERE IN. I believe this will the following code will work but I'm unable to test.
select distinct u.Name, p.PName, u.AccCreateDate, up.BuyDate, u.ID
from Users u
inner join UserPackages up on up.U_ID = u.ID
inner join Packages p on p.PID = up.P_ID
inner join Refers r on r.RefNo = u.UserRef_No
where up.PackageStatus = 1