Query to split table to 50 count group by id and site_id
Help with query
I have a table with thousands of records and I have to query it in batches as 50 group by some columns (id,site_id)
For a particular id I can have multiple invoices (1 or 10 or 50 or 100 invoices)
the combination of id and site_id can also give invoices in multiple invoice count (1 or 10 or 50 or 100)
Now I need to send them in batches of 50 and it has to be grouped based on id and site_id and the count should not be greater than 50. the combination count can be equal to or less than 50
If the count is greater than 50 it can be neglected (e.g id 3 in below table)