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:


SELECT first_name "First Name",  last_name "Last Name" 
FROM employees;

Sample table: employees


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.

What is the difficulty level of this exercise?

New Content: Composer: Dependency manager for PHP, R Programming