I hated all the things I had toiled for under the sun, because I must leave them to the one who comes after me.
References for Ecclesiastes 2:18
And who knows whether that person will be wise or foolish? Yet they will have control over all the fruit of my toil into which I have poured my effort and skill under the sun. This too is meaningless.
References for Ecclesiastes 2:19
So my heart began to despair over all my toilsome labor under the sun.
For a person may labor with wisdom, knowledge and skill, and then they must leave all they own to another who has not toiled for it. This too is meaningless and a great misfortune.
What do people get for all the toil and anxious striving with which they labor under the sun?
References for Ecclesiastes 2:22