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: BINARY
, CHAR
, DATE
, DATETIME
, TIME
, DECIMAL
, SIGNED
, UNSIGNED
.
SELECT COUNT(distinct CONCAT(CAST(ip as char), CAST(sessionid as char))) AS ...