Loading
Lesson 01
Courses / HackerRank SQL Problem Solving Solution Challenges
Weather Observation Station 1 | SQL Basic Select | HackerRank Solution

Video Transcript

In this lesson I will solve the problem of weather observation station 1 from the basic select section in the SQL Category Hacker Rank. So here is the problem, it states that we should query the setting state from the station table. Station table is defined as following, we have the columns ID, city, state, lat, underscore n, long underscore w. Actually, we don't care about ID nor lat in nor long at w for this problem, all we care about is the city column, state column, and we're going to carry those columns from the table station. If you want to get a glimpse of what the table looks like, you can simply go here and right hand side and say select star from station the table name. And click around code to see what the data looks like. As you can see here, this is what the data looks like. You have the ID, it's a number, followed by the city name, followed by the state, in this case an abbreviation, and then we have lat underscore n followed by long underscore w. So basically all we want to do here in this problem is select, we only want to show the name of the city and the state abbreviation. So for that, we simply go here and instead of saying star, so we want to only select the city comma state from station. And I'm using DB2 as a flavor for SQL here. The most popular would be my SQL, so you can do that as well. And be careful because you're going to lose a thing, so you want to copy if you change. Run code here first to make sure it's correct before you submit. As you can see now, we selected the city and state columns. Simply follow the syntax, select, followed by the columns you want to show the data for from, and then the name of the table. You can comma separate every column name. So we got the city, and then we got the state. Too bad this output doesn't put a like a bar separating these two, but it's actually two separate columns being selected. They're not one thing, so be careful with that. So once you think everything's fine, just click submit code. And that's it for Weather Observation Station 1.
No comments yet (loading...)
No comments yet (loading...)
Did you like the lesson? 😆👍
Consider a donation to support our work: