I have a database with 1000 records containing a file name and a file size on each row.
If the SUM of all file sizes exceeds a specific limit, then:
– I need to create a sql query to delete all the remaining rows, from oldest to newest
Any suggestions?
Thanks
Supposing a table created thus:
To get the running sum, use the following query:
To delete the file ID’s above the threshold:
Note: The
order byis optional.