Selecting Consective rows with same Value & calcute the difference between timestamps of same value rows.Please Check What will b error in this query? I have a table in which there are two columns
A_MSISDNs and Incoming_timestamp which is the time of call.  

I want to calculate the time duration between two calls of same MSISDN
e.g:-  


A_MSISDNs        Incoming_timestamp               
420000128321     2018-06-26 06:26:02    
420000128321     2018-06-26 07:04:44    


The Time Duration between Calls by above Same MSISDN is 28 minutes.

For this purpose I made query which is giving error  1064  

Kindly correct my query if there is any syntax error and logic error  



SELECT MSISDN,total_count,TIMESTAMPDIFF(MINUTE, MIN(times), MAX(times)) AS duration

FROM (

SELECT t1.*
, @groupNumber := IF(@prev_MSISDN != t1.MSISDN, @groupNumber + 1, @groupNumber) AS gn
, @prev_msisdn := t1.MSISDN
FROM (

(#t1
#[ itwill returns the msisdn,incoming_timestamp of all msisdn and total count and order them according to their msisdn ,timestamp. We do this beacuse we want to retrive the different timestamp of calls of the same MSISDN 
SELECT tb1.a_msisdn AS 'MSISDN',tb1.incoming_timestamp AS 'Times',tb2.total_count AS 'Total_counts'
FROM cc_info  AS tb1
JOIN 
#{it will count the msisdn whose total_count>=10
(SELECT COUNT(1) AS 'Total_count',a_msisdn
FROM cc_info  
GROUP BY a_msisdn 
HAVING Total_count>=10 
ORDER BY incoming_timestamp) AS tb2
#}
ON tb1.`a_msisdn`=tb2.a_msisdn
WHERE tb1.a_msisdn=420000128321 #it is for testing
ORDER BY tb1.a_msisdn ,tb1.incoming_timestamp 
#]
) AS t1
,(SELECT @groupNumber := 0, @prev_MSISDN := NULL) var_init_subquerysa ORDER BY MSISDN,times 

) AS t2
)
GROUP BY gn,MSISDN
Right before 

) AS t2


is 

 ORDER BY  MSISDN,times


which does not make sense.  If times is to be a table, then it should not be JOINed (with a comma) to another table with an ORDER BY clause.  (Unless you put parens around the subquery.)

Or was that supposed to be a period, not a comma?:  MSISDN.times

When Error 1064 says "near", it means it.