vendredi 22 octobre 2021

SQL Server get random rows depending on the column's sum

For example, I have this table in my SQL Server database :

Document NumberPageMax
First 48
Second 12
Third 4
Fourth 8
Fifth 1
Sixth 3

I need to get a random list of Document for whose the sum of NumberPageMax is equals to 50. If it's not possible to have exactly 50, it's ok to have a little more (first and sixth document for example to have 51).

Do you know if it's possible to do that in SQL and how ?

Thank you !




Aucun commentaire:

Enregistrer un commentaire