为什么我会收到错误:
子查询返回的值超过1。当子查询遵循=,!=,<,< =,>,> =或子查询用作表达式时,不允许这样做。
create view viewAss
as select a.kd_ass,m.nama
from mahasiswa m ,asisten a, honor h
where m.NIM = a.nim and a.kd_ass = h.kd_ass
group by a.kd_ass,m.nama,h.honors
having h.honors > (select avg(h.honors) from honor)
命令已成功完成。
但是,当我跑...
select * from viewAss
错误:
Msg 512,Level 16,State 1,Line 2 子查询返回的值超过1。当子查询遵循=,!=,<,< =,>,> =或子查询用作表达式时,不允许这样做。
答案 0 :(得分:0)
create view viewAss
as
select a.kd_ass
,m.nama
from mahasiswa m
INNER JOIN asisten a ON m.NIM = a.nim
INNER JOIN honor h ON a.kd_ass = h.kd_ass
group by a.kd_ass,m.nama,h.honors
having h.honors > avg(h.honors)