PostgreSQL Basic SELECT Statement: Display specific columns using alias
1. Write a query to display the names (first_name, last_name) using an alias name "First Name", "Last Name".
Sample Solution:
Code:
SELECT first_name "First Name", last_name "Last Name"
FROM employees;
Sample table: employees
Output:
pg_exercises=# SELECT first_name "First Name", last_name "Last Name" pg_exercises-# FROM employees; First Name | Last Name -------------+------------- Steven | King Neena | Kochhar Lex | De Haan Alexander | Hunold Bruce | Ernst David | Austin Valli | Pataballa ..... Alexander | Khoo Shelli | Baida Sigal | Tobias Guy | Himuro Karen | Colmenares Matthew | Weiss Adam | Fripp Payam | Kaufling Shanta | Vollman .... Mozhe | Atkinson James | Marlow TJ | Olson Jason | Mallin Michael | Rogers Ki | Gee Hazel | Philtanker Renske | Ladwig Stephen | Stiles John | Seo Joshua | Patel Trenna | Rajs .... (107 rows)
Practice Online
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: PostgreSQL Basic Simple - Exercises, Practice, Solution
Next: Write a query to get a unique department ID from employee table.
What is the difficulty level of this exercise?
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework