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

    1. <tfoot id='9ivTC'></tfoot>

      1. <small id='9ivTC'></small><noframes id='9ivTC'>

        SQL - 如何选择具有最大值的列的行

        SQL - How to select a row having a column with max value(SQL - 如何选择具有最大值的列的行)

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

              <tbody id='E4KIG'></tbody>

            <legend id='E4KIG'><style id='E4KIG'><dir id='E4KIG'><q id='E4KIG'></q></dir></style></legend>

            <i id='E4KIG'><tr id='E4KIG'><dt id='E4KIG'><q id='E4KIG'><span id='E4KIG'><b id='E4KIG'><form id='E4KIG'><ins id='E4KIG'></ins><ul id='E4KIG'></ul><sub id='E4KIG'></sub></form><legend id='E4KIG'></legend><bdo id='E4KIG'><pre id='E4KIG'><center id='E4KIG'></center></pre></bdo></b><th id='E4KIG'></th></span></q></dt></tr></i><div id='E4KIG'><tfoot id='E4KIG'></tfoot><dl id='E4KIG'><fieldset id='E4KIG'></fieldset></dl></div>
              <bdo id='E4KIG'></bdo><ul id='E4KIG'></ul>
                <tfoot id='E4KIG'></tfoot>
                1. 本文介绍了SQL - 如何选择具有最大值的列的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  date                 value
                  
                  18/5/2010, 1 pm        40
                  18/5/2010, 2 pm        20
                  18/5/2010, 3 pm        60
                  18/5/2010, 4 pm        30
                  18/5/2010, 5 pm        60
                  18/5/2010, 6 pm        25 
                  

                  我需要查询具有 max(value)(即 60)的行.所以,这里我们得到两行.从那以后,我需要当天具有最低时间戳的行(即 18/5/2010,下午 3 点 -> 60)

                  i need to query for the row having max(value)(i.e. 60). So, here we get two rows. From that, I need the row with the lowest time stamp for that day(i.e 18/5/2010, 3 pm -> 60)

                  推荐答案

                  TOP、LIMIT、ROWNUM 等关键字依赖于数据库.请阅读这篇文章了解更多信息.

                  Keywords like TOP, LIMIT, ROWNUM, ...etc are database dependent. Please read this article for more information.

                  http://en.wikipedia.org/wiki/Select_(SQL)#结果限制

                  Oracle:可以使用 ROWNUM.

                  Oracle: ROWNUM could be used.

                  select * from (select * from table 
                  order by value desc, date_column) 
                  where rownum = 1;
                  

                  更具体地回答问题:

                  select high_val, my_key
                  from (select high_val, my_key
                        from mytable
                        where something = 'avalue'
                        order by high_val desc)
                  where rownum <= 1
                  

                  这篇关于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='9hbHH'></tbody>
                  • <tfoot id='9hbHH'></tfoot>
                    <i id='9hbHH'><tr id='9hbHH'><dt id='9hbHH'><q id='9hbHH'><span id='9hbHH'><b id='9hbHH'><form id='9hbHH'><ins id='9hbHH'></ins><ul id='9hbHH'></ul><sub id='9hbHH'></sub></form><legend id='9hbHH'></legend><bdo id='9hbHH'><pre id='9hbHH'><center id='9hbHH'></center></pre></bdo></b><th id='9hbHH'></th></span></q></dt></tr></i><div id='9hbHH'><tfoot id='9hbHH'></tfoot><dl id='9hbHH'><fieldset id='9hbHH'></fieldset></dl></div>

                    1. <legend id='9hbHH'><style id='9hbHH'><dir id='9hbHH'><q id='9hbHH'></q></dir></style></legend>
                            <bdo id='9hbHH'></bdo><ul id='9hbHH'></ul>

                            <small id='9hbHH'></small><noframes id='9hbHH'>