HackerRank

最近在疯狂刷题,推荐一个刷题网站https://www.hackerrank.com/dashboard

题目1、

Query the list of CITY names from STATION that do not start with vowels. Your result cannot contain duplicates.

Input Format

The STATION table is described as follows:

where LAT_N is the northern latitude and LONG_W is the western longitude.

-- Query the list of *CITY* names from **STATION** that *do not start* with vowels. Your result cannot contain duplicates.
方法一:
selectdistinct city
from station
wherecity not like 'A%'  andcity not like 'O%'  andcity not like 'E%'  andcity not like 'I%'  andcity not like 'U%' 方法二:
-- 将^放在封闭的括号中意味着与将其放在括号之外完全不同。将其放在方括号内可使其匹配所有字符,但括号内的字符除外。因此,我们可以写[^ aeiou]而不是写[bcdfghjklmnpqrstvwxyz]
SELECT DISTINCT CITY FROM STATION
WHERE CITY REGEXP '^[^aeiou]';方法三:
select DISTINCT city FROM station WHERE substr(city, 1, 1) NOT IN ('a','e','i','o','u');

题目2、

Query all columns for all American cities in the CITY table with populations larger than 100000. The CountryCode for America is USA.

The CITY table is described as follows:

-- Query all columns for all American cities in the CITY table with populations larger than 100000. The CountryCode for America is USA.
select*
fromCITY
wherecountrycode='USA' and population>100000

题目3、

Query the NAME field for all American cities in the CITY table with populations larger than 120000. The CountryCode for America is USA.

The CITY table is described as follows:

Current Buffer (saved locally, editable)

-- Query the **NAME** field for all American cities in the **CITY** table with populations larger than `120000`. The *CountryCode* for America is `USA`.
select `NAME`
from CITY
where
CountryCode='USA' and  population>120000

题目4、

Query the two cities in STATION with the shortest and longest CITY names, as well as their respective lengths (i.e.: number of characters in the name). If there is more than one smallest or largest city, choose the one that comes first when ordered alphabetically.
The STATION table is described as follows:

-- 使用最短和最长的CITY名称以及它们各自的长度(即名称中的字符数)查询STATION中的两个城市。如果最小或最大城市不止一个,请按字母顺序选择最先出现的城市。
select city, length(city) from station
order by length(city),city asc
limit 1;
select city, length(city) from station
order by length(city) desc
limit 1;

HackerRank数据库题目练习(2)相关推荐

  1. LeetCode数据库题目1-123

    LeetCode数据库题目1-123 175. 组合两个表 难度简单 SQL架构 表1: Person +-------------+---------+ | 列名 | 类型 | +--------- ...

  2. MYSQL将一个人的性别改为女_力扣数据库题目627变更性别

    力扣数据库题目627变更性别 给定一个 salary 表,如下所示,有 m = 男性 和 f = 女性 的值.交换所有的 f 和 m 值(例如,将所有 f 值更改为 m,反之亦然).要求只使用一个更新 ...

  3. 每日一题 第二次考试 数据库题目,7.17数据库面试题目补充

    Python编程 设计一个装饰器函数,如果被装饰的函数返回字符串则将字符串每个单词首字母大写.(10分) def titlize_string(func):@wraps(func)def wrappe ...

  4. 编程题目+数据库题目总结(3)

    目录 编程题 1.字典中保存了一些股票代码(键)及价格(值),用一行代码找出价格最高的股票,输出股票代码.(5分) 2.字典中保存了一些股票代码(键)及价格(值),用一行代码对字典按股票价格从高到低进 ...

  5. leetcode数据库题目1-123题(20-08-14)(1)

    难度简单 SQL架构 表1: Person +-------------+---------+ | 列名 | 类型 | +-------------+---------+ | PersonId | i ...

  6. 数据库题目:张三的 MySQL 学习之路(一)

    题目:张三的 MySQL 学习之路(一) 题目难度:困难 题目描述:张三最近对 MySQL 数据库感兴趣,决定要好好学习数据库,但-学习的道路总是充满艰辛的.张三今天遇到了一个难题,他左思右想.苦思冥 ...

  7. leetcode 数据库题目全部题解

    来源链接:https://leetcode-cn.com/circle/article/vGr1Mc/ 对数据库专题下每道题目,包括会员题目,都做了详细的题解. 题解内容通常有这么几个部分,题目简述. ...

  8. PTA数据库题目集第一章

    判断题 1.外模式/模式映像可以保证数据与程序的逻辑独立性. 2.数据模型是由数据结构.数据操作和完整性约束三部分组成的 3.数据库体系结构按照 模式 . 外模式 和 内模式 三级结构进行组织 4.数 ...

  9. 沈师 PTA 数据库题目及部分解析 第十章

    判断题 1.登记日志文件时必须遵守的一条原则是:必须先写数据库,后写日志文件. F 解析:必须先写日志文件,后写数据库:如果先写了数据库修改,而在运行记录中没有登记这个修改,则以后就无法恢复这个修改了 ...

  10. 力扣数据库题目刷题日记

    一个准备秋招的菜鸟 此前已经在力扣上面刷过一些题目,从今天开始记录刷题 1. Day1 96/97题 难度:中等 解题思路 首先需要读懂题目的意思,必须要保证容量大于相同分数的人数的同时,选择最低的分 ...

最新文章

  1. 解决redhat安装centos yum源的问题
  2. java tag和flt区别,这些年,我爬过的 Android 坑 | 持续更新
  3. 【296天】我爱刷题系列055(2017.11.28)
  4. [Java基础]Lambda表达式的注意事项
  5. python判断奇偶数字符串的拼接_Python字符串拼接方法总结
  6. matlab仿真软件 R2017a版本下载
  7. ubuntu10.10下安装五笔86输入法
  8. 决战行测5000题-数量关系精华版
  9. NOI2022联合省选 题解
  10. Chrome浏览器截屏插件的开发
  11. [Erlang] XML处理方案
  12. 中国区GPS偏移纠正(适用于Google地图)
  13. SQL 使用ADD_MONTHS或ADDDATE实现RFM参数—R(Recency)
  14. Ubuntu无显示器远桌面程连接分辨率低图标大问题解决方法
  15. 问题 G: 向右看齐
  16. 运算符与基本数据类型int和string的方法汇总(二)
  17. 蒟蒻君的刷题日记Day12(线段树专题T4):P8082 [COCI2011-2012#4] KEKS 线段树版题解
  18. 清除acaddoc.lsp
  19. 曾经的经典玄幻小说(-)
  20. 动态规划求解TSP(旅行商)问题

热门文章

  1. DDC及EDID内容简介
  2. vue 使用vue-print-nb 实现打印功能 和 用针式打印机打印模糊问题
  3. 数字图像处理(dip)
  4. 维克仓库管理软件 v3.4 工程网络版 是什么
  5. 文件打不开只读或服务器未响应,Recovery Toolbox for PowerPoint(PPT修复工具)
  6. just help me
  7. VBXtraLib 1.0 下载
  8. AutoCAD2004下载AutoCAD2004中文版安装教程
  9. 恒州诚思——2022-2028全球氯化钬行业调研及趋势分析报告
  10. 华硕A55V,终于解决了无线网指示灯不亮的问题。