String Concatenation in SELECT
Beginner Mode
Objective
Write a SQL query to retrieve the full names of all employees by combining their first and last names. The result should include a single column named full_name, which is the concatenation of first_name and last_name separated by a space. The output should be ordered alphabetically by full_name.
Additional information
- Table Name:
employees - Table Schema:
| Column | Type | Description |
|---|---|---|
| id | INT | The unique identifier for each employee |
| first_name | VARCHAR | The employee's first name |
| last_name | VARCHAR | The employee's last name |
- Output: A list of objects with a single key
full_name. - Constraints:
- Ensure that
full_namecorrectly combinesfirst_nameandlast_namewith a space in between. - The results must be sorted in ascending order based on
full_name.
- Ensure that
Examples
Example 1:
Output:
Input:
| employees | ||
|---|---|---|
| first_name | id | last_name |
| John | 1 | Smith |
| Mary | 2 | Johnson |
| James | 3 | Brown |
| Patricia | 4 | Davis |
| full_name |
|---|
| James Brown |
| John Smith |
| Mary Johnson |
| Patricia Davis |
Code Environment
Sign in or try as guest to run your code.
Track
| Question | Difficulty | Company | Access |
|---|
Need more practice in this area? Explore more questions →
Wix