Solomon kept his wits about him through all of this, but verse 11 concedes that the morning after the night before finally arrived—the time he had to give sober thought to what he had accomplished in his life. "I looked on all the works that my hands had done" coincides with the English expression, "The time came to face the facts."
He finds that, though there had been pleasure in accomplishing, he concludes there had been no real gain in terms of meaning of life. By calling his accomplishments "vanity," he does not mean that nothing was gained from them. Certainly a measure of good came from them, but they were disillusioning. They did not give him lasting satisfaction.
Money and the pleasures it can buy do not lift us out of our earthbound frustration. What is going on under the sun has to be connected to something that is happening somewhere else—in the purpose of God.
John W. Ritenbaugh
Ecclesiastes and the Feast of Tabernacles (Part 2)