所有花费超过1200美元的客户

bbmckpt7  于 2021-07-26  发布在  Java
关注(0)|答案(1)|浏览(404)

我需要写一个查询在这个表上的什么位置

CREATE TABLE sales (
    OrderID INT,
    OrderDate DATE,
    OrderPrice INT,
    OrderQuantity INT,
    customerName VARCHAR(20)
);

这是我的table

+---------+------------+------------+---------------+--------------+
| OrderID | OrderDate  | OrderPrice | OrderQuantity | customerName |
+---------+------------+------------+---------------+--------------+
|       1 | 2005-12-22 |        160 |             2 | Smith        |
|       2 | 2005-08-10 |        190 |             2 | Johason      |
|       3 | 2005-07-13 |        500 |             5 | Baldwin      |
|       4 | 2005-07-15 |        420 |             2 | Smith        |
|       5 | 2005-12-22 |       1000 |             4 | Wood         |
|       6 | 2005-10-02 |        820 |             4 | Smith        |
|       7 | 2005-11-03 |       2000 |             2 | Baldwin      |
+---------+------------+------------+---------------+--------------+

在那里我需要得到所有花费超过1200英镑的独特客户的名字

0tdrvxhp

0tdrvxhp1#

使用聚合和 having :

select customerName
from sales
group by customerName
having sum(orderPrice) > 1200

相关问题