日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

HackerRank数据库题目练习(2)

發布時間:2023/12/20 数据库 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 HackerRank数据库题目练习(2) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。