在特定条件下创建组

creating groups under specific conditions

我有以下 table A(这只是示例),它提供了客户进行预订的渠道:

custNum  channelType  reservationNumber  
 1        web           1
 2        Iphone        2
 1        Android       3
 3        web           4

我正在尝试区分 3 组客户(我想获得他们的客户编号):
1. 只使用网络的客户
2. 仅使用手机渠道的客户
3. 两者都用过的客户

根据上面的例子,结果应该是:
1. 仅限网络 (custNum=3)
2. 仅限蜂窝 (custNum=2)
3. 网络+手机 (custNum=1)

我仅针对网络用户尝试了以下方法(但我知道这是错误的):

sel custNum from A where channelType in ('web');

如有任何帮助,我们将不胜感激。

您需要像这样进行一些条件聚合:

select custNum,
   case 
      when max(case when channelType = 'web' then 1 else 2 end) = 1
        then 'web only'
      when max(case when channelType = 'web' then 2 else 1 end) = 1
        then 'celular only'
      else 'both'
   end
from tab
group by custNum