here is my sample code and have tried multiple options and couldn't get it worked to assign the count(*) to my variable so that I can use that value for later
SELECT @Total = count(*) FROM (
FROM MyDatabase..MyTable T1
GROUP BY T1.ItemID
Thanks in advance.