Hey Joroslav,
What I think you should run first is to run a query to fetch all posts that aren't marked as resolved. Once you have the main parent post id, find all replies to that parent id.
1. Get all parent posts that are not marked as resolved:
[gist]
select * from #__discuss_posts where `answered`=0 and parent_id=0
[/gist]
2. Once you have all the id's, delete all replies to these posts, otherwise it would be an orphan
[gist]
delete from #__discuss_posts where `parent_id` IN (the id's from the first query)
[/gist]
3. Once you have deleted the replies, delete the parent posts
[gist]
delete from #__discuss_posts where `answered`=0 and `parent_id`=0;
[/gist]