Sql组不在内连接中工作 [英] Sql group by not working in inner join

查看:64
本文介绍了Sql组不在内连接中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何以ProjectName的分组顺序获得结果





how do i get the results in grouped order of the ProjectName


string sqlString =
           "SELECT  task.idtask, task.hours, task.overtime,
            task.taskdate, task.description, developers.iddevelopers, developers.developerfname, projects.idprojects, projects.ProjectName" +
           " FROM task" +
           " INNER JOIN developers ON developers.iddevelopers = task.iddevelopers" +
           " INNER JOIN projects ON projects.idprojects = task.idprojects"+
          "GROUP BY projects.ProjectName ";





我的尝试:



iv尝试在select语句中包含每个列,但不是加剧了组,但stil不起作用。



What I have tried:

iv tried including EVERY column in your select statement that is not an aggravate into the group by but stil doesnt work.

推荐答案

你不能拥有结果按ProjectName分组,除非您决定要对其他字段做什么。

You can't have the result grouped by ProjectName unless you decide what you want to do with the other fields.

GROUP BY (Transact-SQL) | Microsoft Docs[^]

但是, select list必须包含在GROUP BY列表中

However, each table or view column in any nonaggregate expression in the select list must be included in the GROUP BY list



所以你需要为每个不是分组factort的列指定聚合函数,如何将处理来自多行的列数据。


So you need to specify an aggregation function for each column which is not a grouping factort, how the column data from multiple rows will be handled.


这篇关于Sql组不在内连接中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆