DR2
Query the following two values from the STATION table
1. The sum o all valuos in LAT N roundod to à scalo of 2 docimal placos.
2. The sum of all vales in LONG_W rounded to s scale ot 2decimal places 2/
Enter your query here and follow these instructions:
Input Format
1. Please append a senicolon ";" at the end of the query and enter your query in a
The STATION table n domcrbod as follow: single 1ine to avoid error.
2. The AS keyword causes errors, so follow this convention: "Select t.Field From
tablel t instead of 3eLect C.het
3. Type your code imediately after comment. Donr leave any blank line.
STATION SELECT
CAST(ROUND(SUM(LAT_N), 2) AS DECIMAL (10, 2)) AS lat,
16 CAST(ROUND (SUM(LONG_W), 2 AS DECIMAL( 10, 2)) AS lon
Field Type 11 FROH
STATION;
13
ID NUMBER Line: 13 Cot 1
1. Upload Code as File
CITY VARCHAR2 (21) () Run Code Subeit Code
STATE VARCHAR2(2)
LAT_N NUMBER You have earned 15.00 points!
10%
ae now 65 poants aoy ftont the bt sta tor your sgl tacdge
LONG W NUMBER
HackerRank Propare Aggregation Japsn Population Fyt Fl Smwn Viw
DR
Query the sum ot the populations for all Japanese cties in CITY. The COUNTRYCOCE fo
Japan is JPN.
1
2/
Input Format
3 Enter your guery here and foll ow these instructions:
Tho CITY table is describod an tollows: L. Please append a senicolon ";" at the end of the query and enter your query ln a
single line to avaid error.
2. The AS keyward causes errors, so follow this convention: "Select t.Field From
tablel t" instead af "select t. Field Froa tablel AS t
CITY b 3. Type your code innediately after comment. Don't leave any blank 1ine,
SELECT
Field Type 16 FROM
SUM POPULATION AS total_populetion
11 CITY
ID NUMBER 12
13
ERE
cOUNTRYcODE 3PN':
4
NAME VARCHAR2(17) Line: 14 Cot: 1
COUNTRYCODE VARCHAR2 (3) t uoload Code as Fie
Run Code Subeit Code
DISTRICT VARCHAR2(20)
POPULATION NUMBER
You have earned I0.00 points!
bnts aswy thohe stat tot yut sql tay 319% 2twB0
https//wwwhackesankcomychallengesjapan populationysutenessions
Ext FlScrn Ve
HackerRank Prepare SOL Apgrogation Wather Obsorvation Station 20
DB2
Aredan is defined as a nurnbe separating the higher hat ot a data set trom the lower
halt Query the median ot the Northern Latitudes (LAT_N) trom STATON and round your
arGwer to 4 decimal places.
Enter your query here and follow these instructions:
Input Format
1. Please append a senicolon ";" at the end of the query and enter your query in a
The STATION table s descrbed as follcw: single line to avoid er ror.
2. The AS keyword causes errors, so follow this canvent ion: "Select t.Field Fro
tablel t" instead of "select t.Field From tablel AS E"
3, Type your code inediately after coment.. Dont leave any blank Line.
STATION WITH OrderedLatitudes AS
SELECT LAT_N, ROW_NUMBER oVER (ORDER BY LAT_M AS Rowtium,
16 cOUNT) OVER ( AS TotalCount
FROM STATION
Field Type 12
SELECT
14 ROUND
ID NUMBER 15 CASE
16 WHEN TotalCoun t $ 2 = 1 THEN
17 SELECT LAT NFRON OrderedLatitudes WHERE ROwtum TotalCount 1 ?
CITY VARCHAR2(21) ELSE
SELECT AVG(LAT
cROM OrderedLatitudes
STATE VARCHAR2(2) 21
22
23
END, 4
AS Median;
MHERE Rowum IN (TotalCount/ 2, TotalCount / 2 + 1)
LAT_N NUMBER ine: 23 Col: 17
. Uokoad Code as Fe
IONG NIMBER Run Code Subait Code
HackerRank Prepare SOL Aggregation Top Earrers
Wa dofne an emplo
nployee's total aarn1rgs to be their monthly saiary x months worked. MySQL
and the maximum total eerning to be the maximum totel earnings for any empioyee in
the Employee table. Write a query to find the maximum total earnings for all employees Enter your query here.
as woll as the total rurmber of ernployoes who have maxirrum total oornng Then prnt 3 /
SELECT
these values as 2 space-separated intogors.
MAX (months salary AS max_total_earnings,
Input Format COUNT ( ) AS employee_count
FROH
The Employee table containing erployee data for a company is described as follows: EmpLoyee
eiER
16 months salary (SELECT MAX (months salary FROM Employee)
11
Column Type Line: 11 Cot: I
1 Upload Code as File
employee_id Integer Run Code Subeit Code
name String Congratulations!
You have passed the sample test cases. Cd the submit button to run you code against all the test cases.
months Integer Sample Test case 0
Yo Output (stdout)
108064 7
DR2
Query the difference between the imun and minimurm populotiors in CITY
Input Format
2
The CITY table is described as follows:
Enter your query here ard follow these instructions:
l. Please append a senicolon ";" at the ond of the query and enter your query in a
single line to avoid error.
2. The AS keyword causes 0 rotto his convent ion: Select t,Field Eror
CITY
3. Type your code innedia
diately after Dent leave any blank Line.
Field Type 8 SELECT
9 MAX (POPULATION) MIN POPULATION) AS population_difference
1e FROM
ID NUMBER 11 CITY:
12
NAME VARCHAR2(17) Line: 2 Colt 1
COUNTRYCODE VARCHAR2 (3) t. Velod Code s File
Run Code Suberit Code
DISTRICT VARCHAR2(20)
POPULATION NUMBER Congratulations!
You hae passed the sarmple test caes Cld the subrnit button to run you code agaist all the tost cases,
Sample Test case 0 Your Output (stcout
HackerRank Prepare Acvanced Select The PADS
3. Type your code tmmediately after comment. Don' t leave any blank line.
Gener ate the following two rosult sots:
1.Quory an alphabotically ordered list o all namos in OCCUPATIONS, immediatoly
SELECT
followed by the first letter at esch proleason as a parenthetical (e: enciosedi 1 nane || ' | | SUBSTRING occupation, 1, 1 | | )
parentheses). For example: AnActorName (A), ADoctorName (D). 1: FROM
1: OCCUPATIONS
AProfessorlame (P). and ASingerkame (S)
ORDER BY
2.uery the number af ocurrencs o each occupaton n 0CCUPATIONS Sort the nane:
occurrences in ascending order, and output them in the following format:
SELECT
'There are a total of* | |cOUNT() || | LOMER Occupation) || 's.
There are a total of [occupation_count] [occupation]s. 18 FRON
19 OCcUPATIONS
20 GRoUP BY
where [occupation_count] s the number ot occurronces ot an occupation in
21 occupation
OCCUPATIONS and [occupation] s the owercase occupation name, if more than 22 ORDER BY
one Occupation has the same [occupation_count]. they should be ordered 23
cOUNT (), occupation;
24
alphabeticaily
25
Nota: There will be at least two antries in the table tor each type of ocupation
Line: 8 Col: 1
Input Format
Upkoad Code as File
Tho OCCUPATIONS tablo is doscrbod as folows Run Code Subeit Code
Column Type Congratulations!
Yo hae passed the sample tast cases Chck the subit buttan ta un your code against all the test cases
Name String