Loading
Lesson 17
Courses / HackerRank SQL Problem Solving Solution Challenges
Weather Observation Station 17 | SQL Aggregation | HackerRank Solution

Video Transcript

Hey everybody, welcome to another lesson. I will do weather observation station 17 from the subsection aggregation Section sequel from hacker rank. So we're given the table station that has five columns ID city state lat underscore n and long underscore W so we're asked to query the long underscore W value for the row that has the smallest lat underscore n That's greater than 38778 that is the lat underscore n has with it be within that range of Greater than 38.778 and make sure to round to four decimal places So let's get started. I choose my sequel and I like to visualize the data initially. So I select star from station Click run code Okay, so if you see these values here for the lat underscore n if you have greater than 38.778 that means this value here wouldn't be included but you for example, you would have to take the lowest and Then from that row you have to take the value from Long underscore W. So to do this. I'm gonna use order by the value of lat underscore and I'm gonna find a row that has the Smallest and from that row I'm gonna select the along W. So here. I'm gonna say first Let's add a where the lat underscore w is greater than 38.778 and Then I'm gonna do order by The value of lat underscore in and in this case it has to be from the lowest to the highest So I can take the very first row that's gonna be the smallest. So this is by default ASC I it's implicit. You don't have to say it but if I want to be explicit as right here ASC ascending and I limit one to only take the very first row out of all this these rows because I know the first one is gonna have the smallest value and Then from that we have to select the value of long and short W. So that's what we put in select But because we want to round it to four decimal places We have to call the round function past the long W value here comma four decimal places close parentheses run code now And there you go have seventy point thirteen seventy eight has been routed to four decimal places submit code And That's weather observation station 17
No comments yet (loading...)
No comments yet (loading...)
Did you like the lesson? 😆👍
Consider a donation to support our work: