This one is probably the most straightforward problem in the Basic Select section. No filters, no conditions, no fancy functions. Just grab two columns from a table and that is it.
The table here is STATION and the task was to get the CITY and STATE columns from it.
Here is what I wrote:
SELECT CITY, STATE
FROM STATION;
That is the whole query. When you do not need all the columns but you need more than one, you just list them out separated by a comma after SELECT. No WHERE clause needed here because there is no filtering going on at all.
Honestly this problem is more about getting comfortable with the idea that you do not always need SELECT star. Sometimes you only want specific columns and listing them out by name is the cleaner way to do it.
Short problem, short solution. Not every query has to be complicated.
Top comments (0)