Chris So
Jan 2, 2021

Actually, there's an even simpler way, without using a subquery.

You can create conditional aggregations in the SELECT clause by using the CASE statement:

SELECT

COUNT(CASE WHEN cre8_dt < '2007-12-22' THEN cust_id END) / COUNT(cust_id)

This should yield the same result for the records before that date.

Chris So
Chris So

Written by Chris So

Data Dude and SQL enthusiast. Occasionally does Pixel art◾

No responses yet