All is meaningless: wisdom, pleasures, toil, advancement and riches. Here is the conclusion of the matter: see 12:13-14.
Solomon wrote Ecclesiastes. What a difference between David and Solomon! David was full of life, praising God with songs (Psalms). Solomon had nearly every material thing a person could want, yet in his old age he says: "All is Meaningless!"