Loading
Lesson 27
Courses / HackerRank SQL Problem Solving Solution Challenges
Employee Names | SQL Basic Select | HackerRank Solution

Summary

SQL Lesson: Querying Employee Names

In this lesson, we will focus on querying employee names from the "employee" table. The table includes the following columns:

  • employee_ID
  • name
  • months
  • salary

Objective

We need to write a SQL query that retrieves the list of employee names in alphabetical order.

SQL Query Structure

To achieve this, we will:

  1. Select the name column.
  2. Source the data from the employee table.
  3. Order the results by the name column in ascending order.

SQL Query

SELECT name 
FROM employee 
ORDER BY name ASC;

Explanation

  • SELECT name indicates we want to fetch the name column.
  • FROM employee specifies the table from which to retrieve the data.
  • ORDER BY name ASC sorts the names in alphabetical (ascending) order.

Result

Executing this query will provide a list of employee names sorted alphabetically, as desired.

Video Transcript

Hey everybody, welcome to another lesson. I will do employee names from the subsection basic select of the SQL section from Hackerrank. So we're given this stable employee that has the columns employee underscore ID, name, months, and salary. And we're asked to write a query to bring the list of employee names. That is, we're only going to query for the name column and alphabetical order. That is, we have to order by name. So let's get to it. I can do select. And I only want the column name. So I'm going to say name from what's the name of this table, it's employee. And because I want to order by alphabetic order name, so I have to say name here and it's simply ASC, which is ascending. So it's going to be alphabetic ascending, if you don't have to write it. So let's do it. That's it. As you can see, the name is order of alphabetically. And that's employee names.
No comments yet (loading...)
No comments yet (loading...)
Did you like the lesson? 😆👍
Consider a donation to support our work: