题解 | #判断其是否有过购买记录#

判断其是否有过购买记录

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也能做,只是答案顺序不一样,如果要保留原表中的顺序最好还是一次性查出来

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务