gpt4 book ai didi

SQL 查询计数所有(未知,已知),未知,已知客户,通过电话 Mac 地址唯一标识

转载 作者:行者123 更新时间:2023-12-02 08:10:32 26 4
gpt4 key购买 nike

表1(客户表)

Id, CustomerId, IsKnownCustomer,phonemacaddress

1, 空 0 00:9a:34:cf:a4

2, 004024 1 00:6f:64:cf:a0:93

3, 004024 1 00:6f:64:cf:a0:93

4, 004003 1 2c:0e:3d:15:12:43

6, 空 0 2c:0e:3d:15:125

7, 004003 1 34:f3:9a:ee:53:a9

8, 004023 1 38:0B:40:DC:BA:3A

9,空 0 4c:66:41:11:26:16

这是表格,需要所有客户、未知客户和已知客户的数据。

输出如下:通过phonemacaddress唯一查找记录。

计数客户,|客户类型|
7 全部

3 未知客户

4 个已知客户

最佳答案

你可以使用 union 和 count

 select count(*), 'all'
from customer
union
select count(*), 'unknown customer'
from customer
where isKnowCustomer = 0
union
select count(*), 'known customer'
from customer
where isKnowCustomer = 1

关于SQL 查询计数所有(未知,已知),未知,已知客户,通过电话 Mac 地址唯一标识,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47512604/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com