SQL assignment
SQL assignment
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
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
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.
STATE VARCHAR2(2) 21
22
23
END, 4
AS Median;
MHERE Rowum IN (TotalCount/ 2, TotalCount / 2 + 1)
. 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
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.
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,
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: