唯一数据

使用 AI 的 SQL 查询入门

Jasmin Ludolf

Senior Data Science Content Developer

业务问题

$$

我们的产品名称有哪些?

我们的客户来自哪里?

我们有多少种产品?

我们与多少个国家合作?

坐在笔记本电脑前的人,旁边是上升的图表和火箭

使用 AI 的 SQL 查询入门

不切实际的方法

SELECT product_name, category
FROM products;
|product_name|category |
|------------|---------|
|Laptop      |Computing|
|Desktop     |Computing|
|Gaming      |Computing|
...
使用 AI 的 SQL 查询入门

引入 DISTINCT:隐含提示

提示产品表中有哪些类别?

SELECT DISTINCT category
FROM products;
|         category         |
|--------------------------|
|Audio                     |
|Computing                 |
|Home Climate & Air Quality|
|Laundry & Cleaning        |
|Kitchen Appliances        |
|Gaming                    |
|Mobile & Accessories      |
|Smart Home                |
|Office Equipment          |
使用 AI 的 SQL 查询入门

引入 DISTINCT:直接提示

提示我们售卖哪些不同的产品类别?

SELECT DISTINCT category
FROM products;
|         category         |
|--------------------------|
|Audio                     |
|Computing                 |
|Home Climate & Air Quality|
|Laundry & Cleaning        |
|Kitchen Appliances        |
|Gaming                    |
|Mobile & Accessories      |
|Smart Home                |
|Office Equipment          |
使用 AI 的 SQL 查询入门

唯一配对

提示有哪些类别与产品名称的唯一组合?

SELECT DISTINCT product_name, category
FROM products;
|product_name        |      category      |
|--------------------|--------------------|
|Dishwasher          |Kitchen Appliances  |
|Wireless Mouse      |Computing           |
|Gaming Console      |Gaming              |
|Bluetooth Headphones|Mobile & Accessories|
|Refrigerator        |Kitchen Appliances  |
...
使用 AI 的 SQL 查询入门

在行业中

 _各地区我们合作的供应商是谁?_

零售和人力资源行业插图

                                                                                                                                             _公司里有哪些职位名称?_
使用 AI 的 SQL 查询入门

DISTINCT 工具

$$

  • 表示使用 DISTINCT 的关键词:
    • "unique"(唯一)
    • "different"(不同)
    • "distinct"(去重)

$$

  • 表中有哪些类别?

$$

开心的人在用笔记本电脑工作

使用 AI 的 SQL 查询入门

Passons à la pratique !

使用 AI 的 SQL 查询入门

Preparing Video For Download...