不使用连接计数

时间:2016-04-03 00:54:05

标签: sql

我的逻辑问题。请帮忙。

我得到的错误是: scroll-content{ overflow: hidden; }

我不明白如何使用count函数进行内部子查询。

  
      
  1. 编写一个名为NoJobs的存储过程,它返回所有没有作业的客户端的客户端名字,姓氏和PhoneNumber。不要使用连接。 (2分)
  2.   
Msg 8120, Level 16, State 1, Line 603
Column 'Client.LastName' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Msg 147, Level 15, State 1, Line 605
An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause or a select list, and the column being aggregated is an outer reference.

1 个答案:

答案 0 :(得分:0)

您的查询中的逻辑很远。您正在使用having子句将ClientID与计数进行比较...您希望它如何工作?

您要做的是跳过group by和having子句,并使用in运算符代替以下条件:

where ClientID not in (select ClientID from job)
相关问题