Show HN: ABC Classic 100 Rankings visualised
classic100.gotski.workers.dev37 pointsby gotski19 comments
select sum( case when prev_cust.cust_id is null then 1 else 0 end) / sum( april_cust_count ) as pc_new_cust
from (
/* get unique customers in April */
select distinct cust_id,
1 as april_cust_count
from orders
where order_date between date '2020-04-01' and date '2020-04-30'
) as april_cust
left join
(
/* get customers with a transaction prior to April */
select distinct cust_id
from orders
where order_date < date '2020-04-01'
) as prev_cust
on april_cust.cust_id =
prev_cust.cust_id
Apologies for the lack of code formatting... I find that when SQL is written with a nice formatting (e.g. Nested sub queries with tabs) it reads a whole lot better.
The beeping happened periodically as I was driving around hairpin bends, and the eye detection was triggered by me turning my head to look towards the oncoming sharp corner.
Not the best situation to have a "safety" alert start chastising you!