For each continent show the number of countries:

SELECT continent, COUNT(name)
FROM world
GROUP BY continent

For each continent show the total population:

SELECT continent, SUM(population)
FROM world
GROUP BY continent

WHERE and GROUP BY. The WHERE filter takes place before the aggregating function.

For each relevant continent show the number of countries that has a population of at least 200000000.

SELECT continent, COUNT(name)
FROM world
WHERE population>200000000
GROUP BY continent

GROUP BY and HAVING. The HAVING clause is tested after the GROUP BY. You can test the aggregated values with a HAVING clause.

Show the total population of those continents with a total population of at least half a billion.

SELECT continent, SUM(population)
FROM world
GROUP BY continent
HAVING SUM(population)>500000000

sqlzoo:using group by and having的更多相关文章

  1. 转:sql语句中GROUP BY 和 HAVING和使用 count()

    在开发时,我们经常会遇到以“累计(count)”或是“累加(sum)”为条件的查询.比如user_num表: id user num 1 a 3 2 a 4 3 b 5 4 b 7   例1:查询出现 ...

  2. sqlzoo易错题

    https://sqlzoo.net/wiki/SELECT_names 答案在:https://github.com/codyloyd/sqlzoo-solutions/blob/master/SQ ...

  3. SQLZOO 习题

    https://sqlzoo.net 8. 美國.印度和中國(USA, India, China)是人口又大,同時面積又大的國家.排除這些國家. 顯示以人口或面積為大國的國家,但不能同時兩者.顯示國家 ...

  4. More JOIN operations -- SQLZOO

    The JOIN operation 注意:where语句中对表示条件的需要用单引号, 下面的译文使用的是有道翻译如有不正确,请直接投诉有道 01.List the films where the y ...

  5. The JOIN operation -- SQLZOO

    The JOIN operation 注意:where语句中对表示条件的需要用单引号, 下面的译文使用的是有道翻译如有不正确,请直接投诉有道 01.Modify it to show the matc ...

  6. SUM and COUNT -- SQLZOO

    SUM and COUNT 注意:where语句中对表示条件的需要用单引号, 下面的译文使用的是有道翻译如有不正确,请直接投诉有道 01.Show the total population of th ...

  7. SELECT within SELECT Tutorial -- SQLZOO

    SELECT within SELECT Tutorial 注意:where语句中对表示条件的需要用单引号, 下面的译文使用的是有道翻译如有不正确,请直接投诉有道 01.List each count ...

  8. LINQ Group By操作

    在上篇文章 .NET应用程序与数据库交互的若干问题 这篇文章中,讨论了一个计算热门商圈的问题,现在在这里扩展一下,假设我们需要从两张表中统计出热门商圈,这两张表内容如下: 上表是所有政区,商圈中的餐饮 ...

  9. Kafka消费组(consumer group)

    一直以来都想写一点关于kafka consumer的东西,特别是关于新版consumer的中文资料很少.最近Kafka社区邮件组已经在讨论是否应该正式使用新版本consumer替换老版本,笔者也觉得时 ...

随机推荐

  1. 20155324《网络对抗技术》web安全基础实践

    20155324<网络对抗技术>web安全基础实践 实验内容 使用webgoat进行XSS攻击.CSRF攻击.SQL注入 实验问答 SQL注入攻击原理,如何防御 ①SQL注入攻击是攻击者在 ...

  2. Hibernate 分页

    public EmailBean[] findByPage(Date begin, Date end, String emailreference, int pageNo, final int pag ...

  3. ue4 staticMesh属性记录

    Light Map Resolution 光照贴图分辨率 Generate Mesh Distancde Field 生成网格距离场(一种不怎么消耗性能的阴影) http://api.unrealen ...

  4. react项目构建

    1.react脚手架 npm install -g create-react-app create-react-app myproject 2.页面配置(bootcdn) <script src ...

  5. oracle 表所占空间统计

    1.通过查询dba_segments Select owner,segment_name,sum(bytes)/1024/1024 as MB from dba_segments group by o ...

  6. SpringBoot文件的上传与下载

    ⒈文件实体类 package cn.coreqi.security.entities; public class FileInfo { private String path; public File ...

  7. 二十三种设计模式之原型模式的C#实现

    原型模式就是通过拷贝快速创建一个新的对象 本例UML如图 ColorBase [Serializable] public abstract class ColorBase { public int R ...

  8. 在django中uwsgi的使用,以及安装

    首先了解wsgi是一个python web服务器,uwsgi实现了wsgi所有的功能,性能稳定,效率高的服务器: 1.安装uwsgi pip install uwsgi 2.配置uwsgi [uwsg ...

  9. CSV文件导入导mysql数据库

    1.导入 基本语法: load data [low_priority] [local] infile 'file_name txt' [replace | ignore] into table tbl ...

  10. podman(libpod)---github简单记录

    这个应该集成了Skopeo 和Buildah. 用于代替docker的工具包,且和cri-o共享后端代码,迟早集成进K8S~~~. (docker肿么办????) github地址: https:// ...