TNG wasn't great on comedy, because they tended towards farce. That's not to say there aren't funny scenes within episodes (often with Data, or a quip from Worf), but most of their intentionally comic episodes fell flat - True Q (Worf aside), Outrageous Okona (is that supposed to be funny?).
DS9 probably had the easiest time, with humour continually threaded throughout episodes, often with Quark or Odo, or a line from Garak, or Bashir/O'Brien. Even the comedy episodes mostly work - Magnificent Ferengi, Little Green Men, Our Man Bashir, Trials and Tribble-ations. The one major misstep is Profit and Lace.