select a.id,a.ssmz,(select count(ssmz) from shop_tourist_key b where b.ssmz=a.ssmz) as count
             from shop_tourist_key a WHERE a.ssmz is not null group by a.ssmz LIMIT 0,3;

select a.id,a.ssmz,(select count(ssmz) from shop_tourist_key b where b.ssmz=a.ssmz) as count
             from shop_tourist_key a where ISNULL(a.ssmz)=false group by a.ssmz order by count DESC
            LIMIT 0,3;

select a.id,a.ssmz,(select count(ssmz) from shop_tourist_key b where b.ssmz=a.ssmz) as count,
 count(distinct a.ssmz)  from shop_tourist_key a group by a.ssmz LIMIT 0,3 ;

mysql去重的更多相关文章

  1. mysql去重查询表中数据

    1.distinct select count(distinct CName) from teble select count(CName) from (select distinct CName f ...

  2. mysql 去重,跨表更新,跨表删除

    一.去重 1.查询出重复的记录 CREATE TABLE push_log_full_2013_10_30_tmp SELECT * FROM `push_log_full` WHERE time B ...

  3. MySql 去重且指定某字段在前的排序方法

    今天遇到一个棘手的数据查找并去重的问题: 情况: 1.取出数据库中的数据: 2.同一字段A,不同情况<值,如A值为:a1,a2>下取出的其他数据可能相同: 3.将2情况下的重复数据< ...

  4. mysql去重的最方便的两种方法

    参考资料:http://blog.csdn.net/guocuifang655/article/details/3993612 方法一: 在使用mysql时,有时需要查询出某个字段不重复的记录,虽然m ...

  5. [mysql]去重:DISTINCT

    SELECT DISTINCT name, age:去掉name字段重复的(需要先写去重的字段):如果想多个取出多个字段重复,需要用group by.

  6. MySQL去重案列(待更新...)

    谈谈distinct 查询单个字段,没问题! SELECT DISTINCT username FROM t_user 但是我想加入id字段,这样写,报错! SELECT id, DISTINCT u ...

  7. 超过70亿条数据的mysql 去重

    1.数据库层面: 2.业务层面:接口去重.浏览器显示端去重:

  8. mysql去重, 把url重复且区为空的中去掉、统计重复数据、、结果集去重合并成一行

    delete from 表名 where id not in (select d.id from (SELECT id FROM 表名 GROUP BY c1,c2,c3,c4)as d) #去重复, ...

  9. mysql 去重的两种方式

    1.distinct一般用于获取不重复字段的条数 使用原则: 1)distinct必须放在要查询字段的开头,不能放在查询字段的中间或者后面 select distinct name from user ...

随机推荐

  1. Git学习总结

    master主分支合并dev分支,代码 :git merge dev ,跳出如下界面.输入:wq,(:wq命令是LINUX命令,强制写入文件并结束),可以强制合并.但为什么会跳出该界面,我也没搞清楚. ...

  2. [LeetCode]Lowest Common Ancestor of a Binary Search Tree

    Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BS ...

  3. 【leetcode】Search Insert Position

    题目描述: Given a sorted array and a target value, return the index if the target is found. If not, retu ...

  4. 第二十九篇:使用SOUI的SMCListView控件

    列表控件是客户端应用最常用的控件之一.列表控件通常只负责显示数据,最多通知一下APP列表行的选中状态变化. 现在的UI经常要求程序猿在列表控件里不光显示内容,还要能和用户交互,显示动画等等,传统的列表 ...

  5. UnicodeToGB2312

    http://www.myluoluo.com/unicodetogb2312.love 你是否遇到类似于:\u5355\u4f4d之类的让人纠结的字符? 一个JS文件中一堆一堆的全都是这种,分析起来 ...

  6. SSH 常用命令解析

    SSH 是什么 SSH(全 称 Secure Shell)是一种加密的网络协议.使用该协议的数据将被加密,如果在传输中间数据泄漏,也可以确保没有人能读取出有用信息.要使用 SSH,目标机器应该安装 S ...

  7. Codeforces 307 div2 E.GukiZ and GukiZiana 分块

    time limit per test 10 seconds memory limit per test 256 megabytes input standard input output stand ...

  8. JS: How to detect my browser version and operating system using JavaScript?

    Example: 1. for IE 11,  navigator.userAgent  returns "Mozilla/5.0 (Windows NT 6.1; WOW64; Tride ...

  9. [数据库]redis与redis操作

    网上搜了以下redis的入门操作,全TM的关于怎么安装配置和性能特点的. 基本的CRUD(Create, Read, Update, Delete)就谁也没说,简直气疯了. 先记录下自己常用的命令,后 ...

  10. React组件属性部类(propTypes)校验

    React组件属性类型(propTypes)校验 Prop 验证 随着应用不断变大,保证组件被正确使用变得非常有用.为此我们引入propTypes.React.PropTypes 提供很多验证器 (v ...