I have table Test1=>ID(INT), NAME(VARCHAR) having values like (1,'One'), (2,'two') ..... (51,'Fifty-one') I want sum of ID of last 5 rows whose ID is divisible by 5. I tried following query but not getting any output.
select sum(ID) from Test1 where id%5 = 0 LIMIT 5 offset (select count(*) from Test1)
So answer should be 50+45+40+35+30=200
Can you please help me out. Thanks
Aucun commentaire:
Enregistrer un commentaire