查询未在Access中的列中输入的计数值

时间:2013-03-21 20:44:28

标签: sql ms-access

这是表格

CREATE TABLE STUDENT
(
School_ID char(3), 
St_LastName char(15), 
St_FirstName char(15), 
St_DOB char(15), 
St_SS# char(15), 
St_Address char(15),
St_City char(15), 
St_State char(2),
st_Zip char(5), 
st_phone char(15)
);

我必须写下查询:确定有多少学生没有电话。

我在ACCESS

中编写了以下查询
SELECT STUDENT.School_ID
FROM STUDENT
WHERE STUDENT.st_phone NOT IN( SELECT STUDENT.st_phone, Count(STUDENT.st_phone) AS StudentWithNoPhone FROM STUDENT
GROUP BY STUDENT.st_phone);

但它不起作用。

1 个答案:

答案 0 :(得分:2)

SELECT STUDENT.School_ID
FROM STUDENT
WHERE STUDENT.st_phone IS NULL OR STUDENT.st_phone = ''

或者我误解了你的问题?