Doing a GROUP BY Statement

Doing a GROUP BY Statement

How do I do a “group by” SQL statement? I want to return all rows and columns with ** records. Here is the data sample:

columnA columnB columnCAAA      2334   jan/01/99 **AAA         4   mar/05/99 BBB        32   feb/20/99 BBB         3   feb/23/99BBB        32   feb/24/99 **CCC     32439   jan/23/99 **DDD       666   may/01/99 EEE       444   mar/03/99 **


  • SELECT columnA columnB columnC
  • GROUP BY ColumnA
  • columnC <= mar/04/99 and the max row, which is in the same group

What’s required is to treat this problem in two passes.

First isolate the records that are the case by selecting the max of Column B grouped by Column A. That will at least get you the highest value for the group.

Next, you need another pass to eliminate the outlying dates.

Sorry this solution isn’t more elegant.

See also  5 Benefits of Using Time Tracking Software

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist