0

我需要创建 SQL 查询:

列出所有不住在伊利诺伊州 (IL)纽约州 (NY)加利福尼亚州 (CA)的客户。按邮政编码以升序对它们进行排序。在结果表中,显示客户姓名、州和邮政编码。

我的查询是

SELECT CUSTOMER_NAME, STATE, POSTAL_CODE
FROM CUSTOMER_T
WHERE STATE NOT IN ('CA', 'FL', 'NJ')
GROUP BY POSTAL_CODE

但它不起作用。

4

2 回答 2

1

试试这个:

SELECT CUSTOMER_NAME, STATE, POSTAL_CODE 
FROM CUSTOMER_T 
WHERE STATE NOT IN ('CA', 'FL', 'NJ') 
Order BY POSTAL_CODE Asc

您不需要按此处分组。将 Group By 替换为 Order By。

于 2013-03-17T16:33:08.830 回答
0

我认为你做错了

SELECT CUSTOMER_NAME, STATE, POSTAL_CODE 
FROM CUSTOMER_T 
WHERE STATE NOT IN ('CA', 'IL', 'NY') 
                           ^     ^
Order BY POSTAL_CODE Asc
^
于 2013-03-17T16:37:48.270 回答