Parallel
Ecclesiastes 2:26
King James Version (1769 Blayney revision, with Apocrypha) · Berean Standard Bible
For God giveth to a man that is good in his sight (note: Heb. before him) wisdom, and knowledge, and joy: but to the sinner he giveth travail, to gather and to heap up, that he may give to him that is good before God. This also is vanity and vexation of spirit.
To the man who is pleasing in His sight, He gives wisdom and knowledge and joy, but to the sinner He assigns the task of gathering and accumulating that which he will hand over to one who pleases God. This too is futile and a pursuit of the wind.