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. 54-locate 简明笔记

    在mlocate数据库中搜索条目 locate [option] pattern 参数 pattern 是locate需要搜索的文件名或者正则表达式 选项 -i              忽略大小写 ...

  2. 如何设置unobtrusive的语言包

    场景:网站是用的validate.unotrusive.js验证的,网站的语言已经切换到繁体了,但是提示语言还是英文. 环境:asp.net mvc4,jquery.validate.unotrusi ...

  3. 理解MySQL数据库覆盖索引

    话说有这么一个表: CREATE TABLE `user_group` ( `id` int(11) NOT NULL auto_increment, `uid` int(11) NOT NULL, ...

  4. Web Api单元测试写法

    例如我们在Web Api项目中有个Controller public class SomeController : ApiController { public HttpResponseMessage ...

  5. 【BZOJ 2555】SubString

    http://www.lydsy.com/JudgeOnline/problem.php?id=2555 一个字符串在原串中的出现次数就是这个字符串对应后缀自动机上的状态的\(|Right|\),要求 ...

  6. The resource identified by this request is only capable of generating responses with characteristics

    [转]今天在调试springMVC的时候,在将一个对象返回为json串的时候,浏览器中出现异常: The resource identified by this request is only cap ...

  7. RSA数字证书管理

    RSA数字证书管理分为以下几个部分: 1:在存储区内创建数字证书: 2:导出数字证书私钥: 3:导出数字证书公钥: 4:导入数字证书; 5:读取数字证书. 1:在.net开发环境中,在证书存储区内创建 ...

  8. dede使用方法----调用列表的标签使用及说明

    列表页的标签: {dede:list pagesize ='16'}---------列表页开始标签,16表示每页显示16条 [field:arcurl/]---------------------- ...

  9. Web 安全:隐藏服务版本号

    前述 为了防止一些恶意用户对 apache.nginx.php 等显示出来的版本信息进行攻击,生产环境需要关闭 web 服务的版本信息: apache 隐藏版本号 修改 httpd.conf,添加如下 ...

  10. 如何用css画出三角形

    看到有面试题里会有问到如何用css画出三角形 众所周知好多图形都可以拆分成三角形,所以说会了画三角形就可以画出很多有意思的形状 画出三角形的原理是调整border(边框)的四个方向的宽度,线条样式以及 ...