I would recommend just define a custom query on your custom table (see example) and run it using query api, or do it directly
DataSet ds = ConnectionHelper.ExecuteQuery("SELECT EventNotes AS IPAddress, COUNT(ItemID) AS LoginCount FROM customtable_FraudAlertLog WHERE UserID = 53 AND EventType='User Login' AND ItemCreatedWhen > '2018-03-15' GROUP BY EventNotes", null, QueryTypeEnum.SQLQuery);