w3resource

SQL Exercise: Produce the output of employees name and job name

SQL employee Database: Exercise-5 with Solution

[An editor is available at the bottom of the page to write and execute the scripts.]

5. From the following table, write a SQL query to list the employee's name and job name as a format of "Employee & Job".

Sample table: employees


Pictorial Presentation:

SQL exercises on employee Database: Produce the output of employees name and job name

Sample Solution:

SELECT emp_name|| '   ' ||job_name AS "Employee & Job"
FROM employees ;

Sample Output:

   Employee & Job
---------------------
 KAYLING   PRESIDENT
 BLAZE   MANAGER
 CLARE   MANAGER
 JONAS   MANAGER
 SCARLET   ANALYST
 FRANK   ANALYST
 SANDRINE   CLERK
 ADELYN   SALESMAN
 WADE   SALESMAN
 MADDEN   SALESMAN
 TUCKER   SALESMAN
 ADNRES   CLERK
 JULIUS   CLERK
 MARKER   CLERK
(14 rows)

Explanation:

The provided query in SQL that retrieves a result set that includes a list of concatenated strings, where each string represents an employee name and job name separated by a space character from the 'employees' table.

The concatenation is performed using the concatenation operator || and a space character (' ') to separate the employee name and job name and the newly created column aliased as "Employee & Job".

Practice Online


Sample Database: employee

employee database structure

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous SQL Exercise: Employee names and salaries are increased by 15% in $.
Next SQL Exercise: Produce the output of employees.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

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/sql-exercises/employee-database-exercise/sql-employee-database-exercise-5.php