Skip to content
Advertisement

Converting Queries into SQL Server syntax

I’ve been getting help from Chegg and most answers given to me don’t work for me. My first task is write a query where it list the employee assigned to the most projects.

One response was:

Error I get:

Msg 1033, Level 15, State 1, Line 3 The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP, OFFSET or FOR XML is also specified.

Second Response is

Error I get is:

Msg 130, Level 15, State 1, Line 8 Cannot perform an aggregate function on an expression containing an aggregate or a subquery.

Third Response was

Error message:

Msg 130, Level 15, State 1, Line 13 Cannot perform an aggregate function on an expression containing an aggregate or a subquery.

Any help on how to resolve either one of these queries is greatly appreciated

Here is the script to create my database if it helps

Advertisement

Answer

You can use subquery to get the employees with the most number of projects, together with max() and count() aggregation functions.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement