PostgreSQL Basic SELECT Statement: Get the length of the name, including first_name and last_name of all the employees
16. Write a query to get the first name, last name and the length of the name, including first_name and last_name of all the employees from employees table.
SELECT first_name,last_name, LENGTH(first_name)+LENGTH(last_name) "Length of Names" FROM employees;
Sample table: employees
pg_exercises=# SELECT first_name,last_name, pg_exercises-# LENGTH(first_name)+LENGTH(last_name) "Length of Names" pg_exercises-# FROM employees; first_name | last_name | Length of Names -------------+-------------+------------------ Steven | King | 10 Neena | Kochhar | 12 Lex | De Haan | 10 Alexander | Hunold | 15 Bruce | Ernst | 10 David | Austin | 11 Valli | Pataballa | 14 .... Alexander | Khoo | 13 Shelli | Baida | 11 Sigal | Tobias | 11 Guy | Himuro | 9 Karen | Colmenares | 15 Matthew | Weiss | 12 .... Steven | Markle | 12 Laura | Bissot | 11 Mozhe | Atkinson | 13 James | Marlow | 11 TJ | Olson | 7 .... Renske | Ladwig | 12 Stephen | Stiles | 13 John | Seo | 7 Joshua | Patel | 11 Trenna | Rajs | 10 ... Hermann | Baer | 11 Shelley | Higgins | 14 William | Gietz | 12 (107 rows)
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a query to get the first names after removing all the leading and trailing blanks of all the employees from employees table.
Next: Write a query to check whether the first_name column of the employees table containing any number.
What is the difficulty level of this exercise?
- New Content published on w3resource :
- 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