Click here to Skip to main content
14,386,033 members
Rate this:
Please Sign up or sign in to vote.
See more:
Following is My SQL server queries
select top 100 COUNT(distinct cast(ip as varchar) + cast(sessionid as varchar)) as ActiveUsr from tblTrackingRTT tr where tr.parent=@parent and
    tr.site=@site and tr.ms_date>=DATEADD(MINUTE, -5, getdate())


I converted this query to Mysql


select  COUNT(distinct cast(ip as varchar) + cast(sessionid as varchar(1))) as ActiveUsr from tblTrackingRTT tr where tr.parent=p_parent and
    tr.site=p_site and tr.ms_date>=TIMESTAMPADD(MINUTE, -5, now()) Limit 100;


its give me following error
"Select is not valid position for this server position excepting : ("

What I have tried:

everything i tried i didnt get it
Posted
Updated 4-Nov-19 2:55am
v2

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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 ...
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100