SELECT 指令让我们能够读取表格中一个或数个栏位的所有资料。这将把所有的资料都抓出,无论资料值有无重复。在资料处理中,我们会经常碰到需要找出表格内的不同资料值的情况。换句话说,我们需要知道这个表格/栏位内有哪些不同的值,而每个值出现的次数并不重要。这要如何达成呢?在 SQL 中,这是很容易做到的。我们只要在 SELECT 后加上一个 DISTINCT 就可以了。DISTINCT 的语法如下:

SELECT DISTINCT "栏位名"
FROM "表格名";
举例来说,若要在以下的表格,Store_Information,找出所有不同的店名时, Store_Information 表格
Store_Name Sales Txn_Date
Los Angeles -Jan-
San Diego -Jan-
Los Angeles -Jan-
Boston -Jan-
我们就打入,
SELECT DISTINCT Store_Name FROM Store_Information;
结果: Store_Name
Los Angeles
San Diego
Boston

Distinct的更多相关文章

  1. [LeetCode] Longest Substring with At Most K Distinct Characters 最多有K个不同字符的最长子串

    Given a string, find the length of the longest substring T that contains at most k distinct characte ...

  2. [LeetCode] Longest Substring with At Most Two Distinct Characters 最多有两个不同字符的最长子串

    Given a string S, find the length of the longest substring T that contains at most two distinct char ...

  3. [LeetCode] Distinct Subsequences 不同的子序列

    Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence ...

  4. SQL中distinct的用法

    SQL中distinct的用法   1.作用于单列 2.作用于多列 3.COUNT统计 4.distinct必须放在开头 5.其他 在表中,可能会包含重复值.这并不成问题,不过,有时您也许希望仅仅列出 ...

  5. Oracle 查询语句(where,order by ,like,in,distinct)

    select * from production;alter table production add productionprice number(7,2); UPDATE production s ...

  6. mysql中distinct的用法

    本事例实验用表task,结构如下 MySQL> desc task; +-------------+------------+------+-----+-------------------+- ...

  7. Distinct Subsequences

    https://leetcode.com/problems/distinct-subsequences/ Given a string S and a string T, count the numb ...

  8. distinct 与 group by 去重

    例如下表格:表名:fruit id Name Price Num 1 西瓜 10 2 2 西瓜 11 2 3 香蕉 10 3 4 桃子 10 2 当我想获取Name不重复的数据,结果如下 id Nam ...

  9. 大数据下的Distinct Count(二):Bitmap篇

    在前一篇中介绍了使用API做Distinct Count,但是精确计算的API都较慢,那有没有能更快的优化解决方案呢? 1. Bitmap介绍 <编程珠玑>上是这样介绍bitmap的: B ...

  10. 扩展lamda表达中distinct按照字段去除重复

    首先,我们定义一个Student类来测试. public class Student { public int ID { get; set; } public string Name { get; s ...

随机推荐

  1. 如何删除GIT中的.DS_Store

    .DS_Store 是什么 使用 Mac 的用户可能会注意到,系统经常会自动在每个目录生成一个隐藏的 .DS_Store 文件..DS_Store(英文全称 Desktop Services Stor ...

  2. Memcached, Redis, MongoDB区别

    mongodb和memcached不是一个范畴内的东西.mongodb是文档型的非关系型数据库,其优势在于查询功能比较强大,能存储海量数据.mongodb和memcached不存在谁替换谁的问题. 和 ...

  3. 1008win7与虚拟机中的linux共享文件的(详细)方法

    转自http://jingyan.baidu.com/article/ca00d56c74dde4e99eebcfd2.html 好东西一起分享 win7与虚拟机中的linux共享文件的(详细)方法 ...

  4. Criteria查询之sqlRestriction()的理解

    sqlRestriction()的理解 在Criteria查询中 使用sqlRestriction()方法来提供SQL语法作限定查询,作为where字句 查看官方给的例子,如下 List cats = ...

  5. tomcat提示警告: An attempt was made to authenticate the locked user"tomcat"

    启动tomcat7之后,运行正常,但是运行一段时间就会提示以下警告: 十二月 04, 2013 5:10:15 下午 org.apache.catalina.realm.LockOutRealm au ...

  6. win10下安装Ubuntu出现win10无法进入的情况

    昨天晚上在win10上安装Ubuntu Kylin16.04系统,结果发现重启的时候进不去windows系统了,而且报的错误是 /EndEntire file path: /ACPI(a0341d,0 ...

  7. bzoj4264: 小C找朋友

    hash大法好 #include <iostream> #include <cstdio> #include <cstring> #include <cmat ...

  8. Java中Comparable和Comparator区别小结

    一.Comparable简介 Comparable是排序接口.若一个类实现了Comparable接口,就意味着该类支持排序.实现了Comparable接口的类的对象的列表或数组可以通过Collecti ...

  9. Anroid Studio入门

    转载:http://www.apkbus.com/forum.php?mod=viewthread&tid=255186&extra=page%3D1%26filter%3Dautho ...

  10. .net config文件 配置类的集合

    1,appconfig文件 <configSections> <section name="ToolConfig" type="DMTools.Tool ...