PostgreSQL String() Function - Exercises, Practice, Solution
PostgreSQL String() Function [14 exercises with solution]
1. Write a query to get the job_id and the ID(s) for those employees who is working in that post.
Partial output of the query:
job_id | Employees ID |
AC_ACCOUNT | 206 |
AC_MGR | 205 |
AD_ASST | 200 |
AD_PRES | 100 |
AD_VP | 101 ,102 |
FI_ACCOUNT | 110 ,113 ,111 ,109 ,112 |
Sample table: employees
2. Write a query to update the phone_number column with '999' where the substring '124' found in that column.
Sample table: employees
3. Write a query to find the details of those employees who contain eight or more characters in their first name.
Sample table: employees
4. Write a query to fill the maximum and minimum salary with leading asterisks whether these two columns does not contain a seven digit number.
Sample table: jobs
5. Write a query to join the text '@example.com' with the email column.
Sample Output :
EMAIL -------------------- [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] - - - - - - - - - - - - - - - - - - - - - -
Sample table: employees
6. Write a query to get the employee id, first name and hire month of an employee.
Sample table: employees
7. Write a query to get the employee id, email id to discard the last three characters.
Sample table: employees
8. Write a query to find all the employees which first name contains all the uppercase letter.
Sample table: employees
9. Write a query to extract the last four character of phone numbers.
Sample table: employees
10. Write a query to get the information about those locations which contain the characters in its street address is on and below the minimum character length of street_address.
Sample table: locations
11. Write a query to display the first word in the job title if the job title contains more than one words.
Sample table: jobs
12. Write a query to display the first name, last name for the employees, which contain a letter 'C' to their last name at 3rd or greater position.
Sample table: employees
13. Write a query that displays the first name and the length of the first name for all employees whose name starts with the letters 'A', 'J' or 'M'. Give each column an appropriate label. Sort the results by the employees' first names.
Sample table: employees
14. Write a query to display the first name and salary for all employees. Form the salary to be 10 characters long, left-padded with the $ symbol. Label the column as SALARY.
Sample table: employees
... More
Structure of 'hr' database :
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/postgresql-exercises/string/
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics