查找一个字段,通常是通过主键回表带回,需避免没有带回的写法。
力扣1174:
# 1.首次订单 with tmp as (select * from Delivery where (customer_id,order_date) in (select customer_id,min(order_date) from Delivery group by customer_id)) # 1.1即时订单 ,tmp1 as (select count(*) as count_immediate from tmp where order_date = customer_pref_delivery_date) # 1.2总订单 ,tmp2 as (select count(*) as count_total from tmp) # 2.查询结果 select distinct round(count_immediate/count_total*100,2) as immediate_percentage from tmp,tmp1,tmp2
-END
标签:count,tmp,专题,customer,date,where,select From: https://www.cnblogs.com/peitongshi/p/16753495.html