Simple SQL that I am stuck on

后端 未结 3 1716
礼貌的吻别
礼貌的吻别 2021-01-29 06:26

What percent of customers are reward members?

ID                 Reward Member
1                       y
2                       y
3                       n
4            


        
3条回答
  •  清歌不尽
    2021-01-29 07:06

    You can use COUNT():

    select
      1.0 *
      count(case when reward_member = 'y' then 1 else 0 end)
      / count(*) 
    from t
    

提交回复
热议问题