HackerRank第一趴–Basic Select

ID number NAME VARCHAR2(17) COUNTRYCODE VARCHAR2(3) DISTRICT VARCHAR2(20) POPULATION number

1. Revising the Select Query I

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

2. Revising the Select Query II

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

3.Select All

Query all columns (attributes) for every row in the CITY table.

4. Select By ID

Query all columns for a city in CITY with the ID 1661.

5.Japanese Cities’ Attribute

Query all attributes of every Japanese city in the CITY table. The COUNTRYCODE for Japan is JPN.

6.Japanese Cities’ Name

Query the names of all the Japanese cities in the CITY table. The COUNTRYCODE for Japan is JPN.

Query a count of the number of cities in CITY having a Population larger than 10,000.

9.Query the average population of all cities in CITY where District is California .

10.Query the average population for all cities in CITY , rounded down to the nearest integer.

11.Query the sum of the populations for all Japanese cities in CITY. The COUNTRYCODE for Japan is JPN.

12.Query the difference between the maximum and minimum populations in CITY.

13.Given the CITY and COUNTRY tables, query the sum of the populations of all cities where the CONTINENT is ‘Asia’.

Note: CITY.CountryCode and COUNTRY.Code are matching key columns.

14.Given the CITY and COUNTRY tables, query the names of all cities where the CONTINENT is ‘Africa’.

Note: CITY.CountryCode and COUNTRY.Code are matching key columns.

15.

ID INTEGER Name String Maks INTEGER

1.Query the Name of any student in STUDENTS who scored higher than Marks. Order your output by the last three characters of each name. If two or more students both have names ending in the same last three characters (i.e.: Bobby, Robby, etc.), secondary sort them by ascending ID.

查询 STUDENTS 中任何得分高于 75 的学生的姓名。 按每个名称的最后三个字符对输出进行排序。 如果两个或多个学生的名字都以相同的最后三个字符结尾(即:Bobby.Robby 等),则按 ID 升序对他们进行二次排序。

解题思路,按照每个名字的最后三个字符排序,order by 和right函数结合使用。

employee_id INTEGER name String months INTEGER salary INTEGER

1.Write a query that prints a list of employee names (i.e.: the name attribute) from the Employee table in alphabetical order.

2.Write a query that prints a list of employee names (i.e.: the name attribute) for employees in Employee having a salary greater than per month who have been employees for less than months. Sort your result by ascending employee_id.

编写一个查询,打印员工姓名列表(即:名称属性),用于 Employee 中薪水大于每月且工作时间少于几个月的员工。 按employee_id 升序对结果进行排序。

3.We define an employee’s total earnings to be their monthly salary*months worked, and the maximum total earnings to be the maximum total earnings for any employee in the Employee table. Write a query to find the maximum total earnings for all employees as well as the total number of employees who have maximum total earnings. Then print these values as 2 space-separated integers.

我们将员工的总收入定义为他们的月薪*工作月数,最大总收入定义为 Employee 表中任何员工的最大总收入。 编写查询以查找所有员工的最大总收入以及拥有最大总收入的员工总数。 然后将这些值打印为 2 个空格分隔的整数。

Original: https://www.cnblogs.com/ruoli-121288/p/16335207.html
Author: 徐若离
Title: HackerRank第一趴–Basic Select

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/620183/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球