Click here to Skip to main content
15,912,072 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Following is My SQL query

SQL
Select CONVERT(nvarchar(4), t/60) + '.' + CONVERT(nvarchar(4), t % 60) as t
		 from (SELECT avg(DATEDIFF(second,tur.start,tur.[end])) as t FROM tblUserTracking tur where tur.start
		 between CONVERT(VARCHAR(11),@FromDt,101)
		 and DATEADD(DAY,1,CONVERT(VARCHAR(11),@Todt,101)) ) as tbl1


I converted in Mysql

SQL
Select CAST(t/60) , '.' , CAST(t % 60) as t
		 from (SELECT avg(TIMESTAMPDIFF(second,tur.start,tur.[end])) as t FROM tblUserTracking tur where tur.start
		 between p_FromDt
		 and p_Todt ) as tbl1


Its give me error

select is not right position server version

What I have tried:

I tried lot still not getting anything
Posted
Updated 5-Nov-19 8:48am
v2
Comments
Richard MacCutchan 5-Nov-19 6:05am    
What error? If you receive an error message then please add the exact message to your question.
Akshay malvankar 5-Nov-19 6:30am    
"select" is not valid at this position for this server version, excepting : '(', with

I think the syntax for CAST() is wrong, see: MySQL CAST() Function[^]
 
Share this answer
 
As RickZeeland mentioned and i showed you in my previous answer[^], you're doing it wrong! So, this:
SQL
Select CAST(t/60) , '.' , CAST(t % 60) as t

becomes to:
SQL
SELECT CONCAT(CAST(t/60 AS CHAR) , '.' , CAST(t % 60 AS CHAR)) as t


I'd strongly recommend to buy a book or/and read MySQL documentation[^].
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900