http://sqlfiddle.com/#!6/30c6fe/4
以下是代码:
Create table employees
(
id integer identity(1,1) primary key,
lastname varchar (16),
pass_num varchar (16)
)
;
insert into employees values ('Ivanov', '11111111');
insert into employees values ('Ivanov', '11111111');
insert into employees values ('Ivanov', '55555555');
insert into employees values ('Petrov', '22222222');
insert into employees values ('Petrov', '22222222');
insert into employees values ('Sidorov', '11111111');
SELECT id, lastname, pass_num
FROM employees emp
GROUP BY lastname, pass_num
HAVING min(id);
和 错误:在预期条件的上下文中指定的非布尔类型的表达式,在')'附近。
答案 0 :(得分:3)
上有错误
HAVING min(id);
期待一个表达
样本
HAVING min(id) = 1;
另外,您的GROUP BY不包括所有不在聚合函数中的列。这应该包括列id
GROUP BY lastname, pass_num