mysqli error: [1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'rank
,concat(firstname,' ',lastname) name
' at line 3] in EXECUTE("SELECT *
FROM (SELECT member_id
,@rank := @rank + 1 as rank
,concat(firstname,' ',lastname) name
,city
,team
,format(yearpoints,1) yearpoints
,format(yearreaction,3) yearreaction
,format(yearspeed,1) yearspeed
,format(yearrate,1) yearrate
,totalshots
FROM (select m.member_id
,concat('',m.firstname,'') firstname
,concat('',m.lastname,'') lastname
,m.city
,m.team
,t.yearpoints
,t.yearreaction
,t.yearspeed
,t.yearrate
,m.totalshots
from t_member m
,(select r.member_no
,avg(r.daypoints) yearpoints
,avg(r.dayreaction) yearreaction
,avg(r.dayspeed) yearspeed
,avg(r.dayrate) yearrate
from (select @rownum := (@member_no=member_no)*(@rownum + 1) as rownum
,@member_no:=member_no as member_no
,s.daypoints
,s.dayreaction
,s.dayspeed
,s.dayrate
from (select td.member_no
,tm.gender
,(year(td.resultdate)-year(tm.birthdate))-(right(td.resultdate,5)'0000-00-00'
and tm.member_no = tac.member_no
and tac.active_ind ='Y'
and tv.event_no=tac.event_no
and td.resultdate between tv.event_date and tv.end_date
and tv.event_id='Baycrest'
order by td.member_no,td.daypoints desc
) s
) r
where r.rownum < 3
group by r.member_no
) t
where t.member_no=m.member_no
order by yearpoints desc ) ctab ) ltab LIMIT 0,50")