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

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

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

      如何按 MAX(日期)选择?

      How to SELECT by MAX(date)?(如何按 MAX(日期)选择?)

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

        <tbody id='Zps7B'></tbody>

        <tfoot id='Zps7B'></tfoot>
          <bdo id='Zps7B'></bdo><ul id='Zps7B'></ul>
          <legend id='Zps7B'><style id='Zps7B'><dir id='Zps7B'><q id='Zps7B'></q></dir></style></legend>

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

                问题描述

                这是表结构:

                CREATE TABLE `reports` (
                  `report_id` int(11) NOT NULL auto_increment,
                  `computer_id` int(11) NOT NULL default '0',
                  `date_entered` datetime NOT NULL default '1970-01-01 00:00:00',
                  `total_seconds` int(11) NOT NULL default '0',
                  `iphone_id` int(11) default '0',
                  PRIMARY KEY  (`report_id`),
                  KEY `computer_id` (`computer_id`),
                  KEY `iphone_id` (`iphone_id`)
                ) ENGINE=MyISAM AUTO_INCREMENT=120990 DEFAULT CHARSET=latin1
                

                我需要一个 SELECT 语句,从最新输入的 date_entered 中列出每个 computer_idreport_id,并且我不知道该怎么做.

                I need a SELECT statement that will list the report_id per computer_id from latest entered date_entered, and I have no clue how to do that.

                推荐答案

                应该这样做:

                SELECT report_id, computer_id, date_entered
                FROM reports AS a
                WHERE date_entered = (
                    SELECT MAX(date_entered)
                    FROM reports AS b
                    WHERE a.report_id = b.report_id
                      AND a.computer_id = b.computer_id
                )
                

                这篇关于如何按 MAX(日期)选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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 查询中包含缺失的月份)

                <tfoot id='9sO14'></tfoot>

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

                    <bdo id='9sO14'></bdo><ul id='9sO14'></ul>

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