First, Perry has provided some excellent information.
Second ... you asked if there was 'an sql solution' ... answer: maybe.
It's a hidden admin tool ... only admins can execute. But before you do, make a backup of the database (an SQL dump). And you should also know this is considered to be an experimental tool. But, I have used it successfully before and it did fix quiz bank issues. Also know how to restore that sql dump you make.
Then go to: https://yoursite/admin/tool/health/
That will grind away some ... be patient.
If there are 'health' problems it will show them. Many times you will see quizzes or question bank with issues. There is a 'Solution' button at the bottom. Click it.
What you will see is a recommendation ... if it can find one ... presented to you as an SQL query. Copy that SQL query. Get into whatever interface you have (cli or phpmyadmin or webmin or ???) that will allow you to make a query of the database, paste the SQL and hit enter or whatever you have to click on to execute.
That might grind away some more ... let it finish ... it will then re-run the check.
Fingers crossed ... it will fix some stuff and you'll have a 'green' screen.
Now go look at your quiz stuff again.
Again ...'fingers crossed' ... but warn your mileage might vary. :|
'spirit of sharing', Ken