博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HackerRank【SQL2】
阅读量:4993 次
发布时间:2019-06-12

本文共 2774 字,大约阅读时间需要 9 分钟。

The STATION table is described as follows:

1、Weather Observation Station 1

Query a list of CITY and STATE from the STATION table.

select CITY,STATE from STATION;

2、Weather Observation Station 3

Query a list of CITY names from STATION with even ID numbers only. You may print the results in any order, but must exclude duplicates from your answer.

select distinct CITY from STATION where mod(ID,2) = 0;

3、Weather Observation Station 4

 In other words, find the difference between the total number of CITY entries in the table and the number of distinct CITY entries in the table.

select count(CITY)-count(distinct CITY) from STATION;

4、Weather Observation Station 5

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.

SELECT CITY, LENGTH(CITY) FROM STATION ORDER BY LENGTH(CITY),CITY LIMIT 1;SELECT CITY, LENGTH(CITY) FROM STATION ORDER BY LENGTH(CITY) DESC,CITY LIMIT 1;

5、Weather Observation Station 6

Query the list of CITY names starting with vowels (i.e., aeio, or u) from STATION. Your result cannot contain duplicates.

SELECT distinct CITY FROM STATION WHERE CITY REGEXP '^[aeiou]';

6、Weather Observation Station 7

Query the list of CITY names ending with vowels (a, e, i, o, u) from STATION. Your result cannot contain duplicates.

SELECT distinct CITY FROM STATION WHERE CITY REGEXP '[aeiou]$';

7、Weather Observation Station 8

Query the list of CITY names from STATION which have vowels (i.e., a, e, i, o, and u) as both their first and last characters. Your result cannot contain duplicates.

SELECT distinct CITY FROM STATION WHERE CITY REGEXP '^[aeiou].*[aeiou]$';

8、Weather Observation Station 9

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

SELECT distinct CITY FROM STATION WHERE CITY REGEXP '^[^aeiou]';

9、Weather Observation Station 10

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

SELECT distinct CITY FROM STATION WHERE CITY REGEXP '[^aeiou]$';

10、Weather Observation Station 11

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

SELECT distinct CITY FROM STATION WHERE CITY REGEXP '^[^(aeiou)]|[^(aeiou)]$';

11、Weather Observation Station 12

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

SELECT distinct CITY FROM STATION WHERE CITY REGEXP '^[^(aeiou)].*[^(aeiou)]$';

 

转载于:https://www.cnblogs.com/wzs-python/p/11214943.html

你可能感兴趣的文章
样本不均衡下的分类损失函数
查看>>
node启动服务后,窗口不能关闭。pm2了解一下
查看>>
vsCode 改变主题
查看>>
【vijos】【树形dp】佳佳的魔法药水
查看>>
聚合新闻头条
查看>>
Ubuntu 关闭锁屏界面的 on-screen keyboard
查看>>
凸优化学习笔记
查看>>
使用ehcache-spring-annotations开启ehcache的注解功能
查看>>
Charles设置HTTPS抓包
查看>>
NGUI出现Shader wants normals, but the mesh UIAtlas doesn't have them
查看>>
Boost.Asio c++ 网络编程翻译(14)
查看>>
Codeforces Round #306 (Div. 2) D.E. 解题报告
查看>>
uva 1557 - Calendar Game(博弈)
查看>>
HDU1051 Wooden Sticks 【贪婪】
查看>>
十大经典数据挖掘算法
查看>>
Rhythmbox乱码的解决的方法
查看>>
中纪委:抗震中官员临危退缩玩忽职守将被严处
查看>>
MySQL 8.0.12 基于Windows 安装教程
查看>>
在hue中使用hive
查看>>
eclipse快捷键
查看>>