9. 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.
Essential
SQL 0/33
Spark 0/20
Snowflake 0/22
Python 0/24
Need more practice in this area? Explore more questions →
Wix
Revolut
Accenture
Adobe
Google
LinkedIn
Samsung
Datadog
Dropbox
Meta
OpenAI
Hulu
Uber
X
DoorDash
Anthropic
Amazon
ActivisionBlizzard
Vercel
Crypto.Com
Zscaler
DeutscheBank
Apple
GoDaddy
GitLab
BMW
PayPal
Snowflake
AMD
Twilio
Atlassian
JPMorgan
NVIDIA
IBM
Databricks
Coinbase
Cisco
Robinhood
Twitter
Microsoft
Palantir
Netflix
VMware
Cloudflare
Stripe
Lyft
Salesforce
GitHub
Bloomberg
Airbnb
Walmart
SAP
HashiCorp
Instacart
Mastercard
Intel
Visa
Tesla