Doing a GROUP BY Statement

Question:
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 **

Conditions:

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

Answer:
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.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may