Homer is arrested for drunk driving, and Marge persuades him to swear off beer for a month, which gives Homer a whole new outlook on life. Meanwhile, after Bart ruins Lisa's science fair project, she comes up with a new experiment: To determine which is smarter, Bart or a hamster.
The episode opens at the school science fair, with Bart presenting a Go-Go Ray: He zaps all the teachers, causing them to dance uncontrollably. Principal Skinner declares "First Prize" over and over, while Bart's dream fades out to Lisa saying into Bart's ear "First prize...first prize..." She explains she was "just screwing with [his] mind."
At breakfast, Lisa shows the family her science fair project: a genetically engineered tomato she hopes will cure world hunger. Bart's actual project is the effect of cigarettes on canines, mainly Santa's Little Helper, but Marge orders Bart to cut it out. Meanwhile, Homer plans to duck out of work and go on a tour of the Duff Brewery with Barney. At the brewery the two partake in free samples, Barney much more than Homer. Homer who has hardly had anything refuses to let Barney drive home after the tour since he drank enough to pass out, Lou, Eddie and Wiggum who have been waiting outside the factory for anyone on the tour to drive away pull him over and despite passing a sobriety test flawlessly (touching his nose with his fingers alternately while balancing on one foot and saying the alphabet) he is arrested when Barney tells them to use the breathalyzer. His license is revoked, and he must attend traffic school and Alcoholics Anonymous meetings. Meanwhile Barney, who is obviously drunk, is allowed to drive away after running over Wiggum.
After school 3 days before the science fair, Lisa leaves her super tomato under Bart's care for a moment, who's juvenile mind takes over when he sees the opportunity to hurl it at a bent-over Skinner forgetting that it was Lisa's project. Lisa appeals to her mother for help, who suggests she run a hamster through a maze. She takes the idea to heart, but instead of just testing the intelligence of a rodent, she pits a hamster against an unknowing Bart to find out which is smarter. Lisa tests both the hamster and Bart first in acquiring out of reach food, then in the electroshock theory. After two tests, the hamster leads 2-0.
In bed, Marge gives Homer a magazine quiz about his drinking. Hearing his answers, she asks him to give up beer for a month, to which he finally agrees. Homer reminisces about the time he first drank beer, passing out listening to Queen, and is taunted by ubiquitous sights of beer, but later comes to realize the fact that watching baseball sober is boring, and that beer commercials falsely state that beer transforms angry feminists into attractive swimsuit models who cling to ordinary men.
Meanwhile Bart finds Lisa's project notes and hides them. He plans to lead her on a treasure hunt to get them back but she finds them after just a minute. At the science fair, Marge says she isn't to sure about the idea of Liasa using her brother as a test subject, but Lisa insists that it's all scientific theory (immediately after her monologue reveals Lisa's true intentions of getting back at Bart). Unfortunately for Lisa, her project and chance for humiliating Bart are both ruined by Bart's project: "Can hamsters fly planes?". Lisa tries to protest that the project has no scientific merit, but everyone ignores her. A cute hamster flying a miniature plane wins over Skinner, who hands Bart the winning ribbon for real, much to Lisa's dismay.
At Homer's first AA meeting, he confesses that his desperation led him to "sneak into the football stadium and suck the dirt underneath the bleachers". When Reverend Lovejoy says that after finishing AA he will never drink a beer again, Homer screams and runs away. However, as time goes by Homer also exhibits more positive changes, such as his belly getting smaller and has saved over a hundred dollars. After 30 days, Marge is proud of Homer for upholding his end of his deal, while thirsty Homer rushes back to Moe's, money in hand. Marge argues that just because Homer honored his alcohol-free month does not mean he has to jump off the wagon the moment it is over. Homer goes anyway, and is about to drink up when he sees what effect alcohol has had on the barflies, and heads home. The episode finishes with Homer and Marge riding a bike into the sunset.