First of all, i'd start from counting the number of opening and closing parenthesis...
Second of all, i'd use CONCAT
] function to return concatenated string and use proper data type:
Quote: The target type can be any one of the following types:
SELECT COUNT(distinct CONCAT(CAST(ip as char), CAST(sessionid as char))) AS ...