douling0053 2014-05-25 20:37
浏览 34
已采纳

不要计算MySql数据库中的重复条目[重复]

This question already has an answer here:

I have a MySQL Table like this:

+-----------+--------------+------+-----+------------------+-------+
| Field     | Type         | Null | Key | Default          | Extra |
+-----------+--------------+------+-----+------------------+-------+
| _m        | int(1)       | NO   |     | 0                |       |
| Timestamp | int(11)      | NO   | PRI | 0                |       |
| Address   | varchar(8)   | NO   | PRI | 0000000a         |       |
| Message   | varchar(255) | NO   | PRI | <NO_MESSAGE>     |       |
| Location  | varchar(100) | NO   |     | <NEED_TO_BE_SET> |       |
+-----------+--------------+------+-----+------------------+-------+

There are Columns like this:

+-----------+---------+-----------------+
| Timestamp | Address | Message         |
+-----------+---------+-----------------+
| 000000001 | A       | Some Text       |
| 000000001 | B       | Some Text       |
| 000000002 | H       | Some Other Text |
| 000000005 | I       | Some Third Text |
+-----------+---------+-----------------+

(I've removed "_m" and "Location" because it's not necessary. Timestamp and Address are censored because its sensitive data)

This table contains signals.
There can be one unique signals which are send to multiple Addreses (Like row 1 and 2)

A unique signal is (should ... be) represented by a unique entriy in the "Message" Field. In this case there

How can i count only the unique signals? (In this case there are 3 of them)

</div>
  • 写回答

1条回答 默认 最新

  • douqianzha6213 2014-05-25 20:42
    关注

    you can use:

        select count(distinct message) from your_table
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序