Loading
Lesson 34
Courses / HackerRank SQL Problem Solving Solution Challenges
Japan Population | SQL Aggregation | HackerRank Solution

Video Transcript

Hey everybody, I will do Japan population from the aggregation subsection of SQL and hacker rank. So we're given the table city has the columns ID, country code district and population. We're asked to query the sum of populations for all Japanese cities. So if you want to get a Japanese city that is a row for a city, you have to filter by the country code having the value JPN. And then we take all the populations and we're going to use the sum function. So let's get started. We can use DB2 or MySQL. So I'm going to do select star from city and from this we're going to modify this query to have the correct answer. So first we have to do where. So where the country code column has the value is equal to JPN. That way we filter all the rows to only having Japanese cities. And we have to take the column population so select population. Matt, we need to add them up, right? So we're going to do the function sum of population like so. And that's it. I'm going to go submit code. And here's the sum of the population according to this data.
No comments yet (loading...)
No comments yet (loading...)
Did you like the lesson? 😆👍
Consider a donation to support our work: