The code below will handle different lengths after the "@", but this code will get an error if the @ is missing:SELECT user_logon , order_number, SUBSTRING(user_logon, CHARINDEX('@', user_logon + '@') + 1, CHARINDEX('.', user_logon + '.', CHARINDEX('@', user_logon + '@')) - CHARINDEX('@', user_logon + '@') - 1) AS country, COUNT(*) CountOfLinesPerOrder , MONTH(createDate) AS MDate , YEAR(createDate) YDate FROM SC_RequestData WHERE order_number IS NOT NULL AND createDate >= '20130401' AND createDate < '20140101'GROUP BY order_number, user_logon , MONTH(createDate) , YEAR(createDate), SUBSTRING(user_logon, CHARINDEX('@', user_logon + '@') + 1, CHARINDEX('.', user_logon + '.', CHARINDEX('@', user_logon + '@')) - CHARINDEX('@', user_logon + '@') - 1)ORDER BY order_number