LIMIT Problem

I can not use MySQL Limit Func. in SC apps. I’m working with millions of data so I need to Use LIMIT. I couldn’t see any alternative for Limit and I need to solve this problem for my project.

Edit: I thought solved but it only works when I don’t use Group by. But I need to use group by. So how can we solve that?

In this case I think the only workable solution is by creating views.