题解 | #判断其是否有过购买记录#
判断其是否有过购买记录
https://www.nowcoder.com/practice/5cddad8995974b0c915ab89961428ee0
# select customer_id, 1 if_placed_order # from customers_info # where not isnull(latest_place_order_date) # union all # select customer_id, 0 if_placed_order # from customers_info # where isnull(latest_place_order_date) select customer_id, if(latest_place_order_date,1,0) if_placed_order from customers_info
union all也能做,只是答案顺序不一样,如果要保留原表中的顺序最好还是一次性查出来