What Can I Select When I Group?
April 25, 2007 Dear highly esteemed professional colleague
It’s not uncommon for someone to ask me for help with error SQL0122, which involves SQL commands that use the GROUP BY clause to produce summary figures. Since I see this error over and over and over, I thought it would be good to explain how summary queries work. The standard rule I hear is that the SELECT clause of summary queries can list aggregate fields (those in the GROUP BY clause), expressions that are in the GROUP BY clause, and column functions, such as COUNT, SUM, and AVG. That’s close, but slightly inaccurate. A reader who contacted me recently |