<small id='S3bGz'></small><noframes id='S3bGz'>

      <bdo id='S3bGz'></bdo><ul id='S3bGz'></ul>

  • <i id='S3bGz'><tr id='S3bGz'><dt id='S3bGz'><q id='S3bGz'><span id='S3bGz'><b id='S3bGz'><form id='S3bGz'><ins id='S3bGz'></ins><ul id='S3bGz'></ul><sub id='S3bGz'></sub></form><legend id='S3bGz'></legend><bdo id='S3bGz'><pre id='S3bGz'><center id='S3bGz'></center></pre></bdo></b><th id='S3bGz'></th></span></q></dt></tr></i><div id='S3bGz'><tfoot id='S3bGz'></tfoot><dl id='S3bGz'><fieldset id='S3bGz'></fieldset></dl></div>
    1. <tfoot id='S3bGz'></tfoot>
      <legend id='S3bGz'><style id='S3bGz'><dir id='S3bGz'><q id='S3bGz'></q></dir></style></legend>
      1. SQL 不是单组组函数

        SQL not a single-group group function(SQL 不是单组组函数)
          <tbody id='uZquD'></tbody>
          <bdo id='uZquD'></bdo><ul id='uZquD'></ul>

              <i id='uZquD'><tr id='uZquD'><dt id='uZquD'><q id='uZquD'><span id='uZquD'><b id='uZquD'><form id='uZquD'><ins id='uZquD'></ins><ul id='uZquD'></ul><sub id='uZquD'></sub></form><legend id='uZquD'></legend><bdo id='uZquD'><pre id='uZquD'><center id='uZquD'></center></pre></bdo></b><th id='uZquD'></th></span></q></dt></tr></i><div id='uZquD'><tfoot id='uZquD'></tfoot><dl id='uZquD'><fieldset id='uZquD'></fieldset></dl></div>
            1. <legend id='uZquD'><style id='uZquD'><dir id='uZquD'><q id='uZquD'></q></dir></style></legend>

                <small id='uZquD'></small><noframes id='uZquD'>

                  <tfoot id='uZquD'></tfoot>
                  本文介绍了SQL 不是单组组函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  当我运行以下 SQL 语句时:

                  When I run the following SQL statement:

                  SELECT MAX(SUM(TIME))
                  FROM downloads
                  GROUP BY SSN
                  

                  它返回客户下载的最大总和值,但是,如果我尝试通过将其添加到 select 语句中来查找该最大值所属的社会保险号:

                  It returns the maximum sum value of downloads by a customer, however if I try to find the social security number that that max value belongs to by adding it to the select statement:

                  SELECT SSN, MAX(SUM(TIME))
                  FROM downloads
                  GROUP BY SSN
                  

                  我收到以下错误:

                  不是单组群功能

                  我不明白为什么它会抛出这个错误.谷歌搜索提出了以下操作:

                  I do not understand why it is throwing this error. A google search came up with the following action:

                  从 SELECT 列表中删除组函数或单个列表达式,或者添加一个包含列出的所有单个列表达式的 GROUP BY 子句

                  Drop either the group function or the individual column expression from the SELECT list or add a GROUP BY clause that includes all individual column expressions listed

                  从我认为这是说- 删除分组功能会使总和值无效- 删除单个列表达式 (SSN) 只会给我最大总和- 不确定第三部分.

                  From what I think this is saying - dropping the group function makes the sum value invalid - droping the individual column expression (SSN) will just give me the max sum - not sure about that third part.

                  谁能指导正确的方向?

                  -托梅克

                  TIME 在这个数据库中是指下载的次数

                  TIME in this database refers to the number of times downloaded

                  推荐答案

                  简单地说,问题是查询中特定 SSN 的 SUM(TIME) 是单个值,因此它反对 MAX,因为它使没有意义(单个值的最大值是没有意义的).

                  Well the problem simply-put is that the SUM(TIME) for a specific SSN on your query is a single value, so it's objecting to MAX as it makes no sense (The maximum of a single value is meaningless).

                  不确定您使用的是什么 SQL 数据库服务器,但我怀疑您想要更像这样的查询(使用 MSSQL 背景编写 - 可能需要一些翻译到您正在使用的 sql 服务器):

                  Not sure what SQL database server you're using but I suspect you want a query more like this (Written with a MSSQL background - may need some translating to the sql server you're using):

                  SELECT TOP 1 SSN, SUM(TIME)
                  FROM downloads
                  GROUP BY SSN
                  ORDER BY 2 DESC
                  

                  这会给你最高总时间和总时间的SSN.

                  This will give you the SSN with the highest total time and the total time for it.

                  编辑 - 如果你有多个相同的时间并且想要它们全部你会使用:

                  Edit - If you have multiple with an equal time and want them all you would use:

                  SELECT
                  SSN, SUM(TIME)
                  FROM downloads
                  GROUP BY SSN
                  HAVING SUM(TIME)=(SELECT MAX(SUM(TIME)) FROM downloads GROUP BY SSN))
                  

                  这篇关于SQL 不是单组组函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                  SQL query to group by day(按天分组的 SQL 查询)
                  What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                  MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                  MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                  Include missing months in Group By query(在 Group By 查询中包含缺失的月份)

                    <tbody id='osYAI'></tbody>

                      • <legend id='osYAI'><style id='osYAI'><dir id='osYAI'><q id='osYAI'></q></dir></style></legend>

                          <small id='osYAI'></small><noframes id='osYAI'>

                        • <i id='osYAI'><tr id='osYAI'><dt id='osYAI'><q id='osYAI'><span id='osYAI'><b id='osYAI'><form id='osYAI'><ins id='osYAI'></ins><ul id='osYAI'></ul><sub id='osYAI'></sub></form><legend id='osYAI'></legend><bdo id='osYAI'><pre id='osYAI'><center id='osYAI'></center></pre></bdo></b><th id='osYAI'></th></span></q></dt></tr></i><div id='osYAI'><tfoot id='osYAI'></tfoot><dl id='osYAI'><fieldset id='osYAI'></fieldset></dl></div>

                        • <tfoot id='osYAI'></tfoot>
                            <bdo id='osYAI'></bdo><ul id='osYAI'></ul>