• <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(日期)选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                Building a comma separated list?(建立一个逗号分隔的列表?)
                Errors in SQL Server while importing CSV file despite varchar(MAX) being used for each column(尽管每列都使用了 varchar(MAX),但在导入 CSV 文件时 SQL Server 中出现错误)
                How can I import an Excel file into SQL Server?(如何将 Excel 文件导入 SQL Server?)
                Export table to file with column headers (column names) using the bcp utility and SQL Server 2008(使用 bcp 实用程序和 SQL Server 2008 将表导出到带有列标题(列名称)的文件)
                Concat field value to string in SQL Server(将字段值连接到 SQL Server 中的字符串)
                SQL Server Bulk insert of CSV file with inconsistent quotes(SQL Server 批量插入带有不一致引号的 CSV 文件)

                <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>