I have a blog under a sub-domain, let's say it's
test.example.com. I want to move all my sub-domain content to my main domain
example.com and delete my sub-domain. How much will this affect my SEO rankings? And how can I minimize the amount it gets affected?
If you manage redirection properly then you should be fine.
Move your blog (test.example.com) to example.com.
Once this is done then just redirect your sub-domain pages to respective pages on the website.
Old Blog: test.example.com => Blog
test.example.com/blog-page1 => Blog Page
Once this is moved to example.com then you should have pages on your main domain like:
Now, with regards to redirection (301), depending on your server type you may be able to redirection at sub domain level. So any sub domain page will automatically get redirected to a respective page on the main website. If this may be hard then you can do individual redirection.