w3resource
SQL exercises

SQL JOINS on HR Database: Display the full name of employee with ID and present country where (s)he is working

SQL JOINS on HR Database: Exercise-27 with Solution

27. Write a query in SQL to display the full name (firt and last name ) of employee with ID and name of the country presently where (s)he is working.

Sample table: countries


Sample table: locations


Sample table: employees


Sample table: departments


Sample Solution:

SELECT first_name || ' ' || last_name AS Employee_name, 
	employee_id, country_name 
		FROM employees 
			JOIN departments USING(department_id) 
JOIN locations USING( location_id) 
JOIN countries USING ( country_id);

Sample Output:

employee_name	employee_id	country_name
Steven King		100	United States of America
Neena Kochhar		101	United States of America
Lex De Haan		102	United States of America
Alexander Hunold	103	United States of America
Bruce Ernst		104	United States of America
David Austin		105	United States of America
Valli Pataballa		106	United States of America
Diana Lorentz		107	United States of America
Nancy Greenberg		108	United States of America
Daniel Faviet		109	United States of America
John Chen		110	United States of America
Ismael Sciarra		111	United States of America
Jose Manuel Urman	112	United States of America
Luis Popp		113	United States of America
Den Raphaely		114	United States of America
Alexander Khoo		115	United States of America
Shelli Baida		116	United States of America
Sigal Tobias		117	United States of America
Guy Himuro		118	United States of America
Karen Colmenares	119	United States of America
Matthew Weiss		120	United States of America
Adam Fripp		121	United States of America
Payam Kaufling		122	United States of America
Shanta Vollman		123	United States of America
Kevin Mourgos		124	United States of America
Julia Nayer		125	United States of America
Irene Mikkilineni	126	United States of America
James Landry		127	United States of America
Steven Markle		128	United States of America
Laura Bissot		129	United States of America
Mozhe Atkinson		130	United States of America
James Marlow		131	United States of America
TJ Olson		132	United States of America
Jason Mallin		133	United States of America
Michael Rogers		134	United States of America
Ki Gee			135	United States of America
Hazel Philtanker	136	United States of America
Renske Ladwig		137	United States of America
Stephen Stiles		138	United States of America
John Seo		139	United States of America
Joshua Patel		140	United States of America
Trenna Rajs		141	United States of America
Curtis Davies		142	United States of America
Randall Matos		143	United States of America
Peter Vargas		144	United States of America
Winston Taylor		180	United States of America
Jean Fleaur		181	United States of America
Martha Sullivan		182	United States of America
Girard Geoni		183	United States of America
Nandita Sarchand	184	United States of America
Alexis Bull		185	United States of America
Julia Dellinger		186	United States of America
Anthony Cabrio		187	United States of America
Kelly Chung		188	United States of America
Jennifer Dilly		189	United States of America
Timothy Gates		190	United States of America
Randall Perkins		191	United States of America
Sarah Bell		192	United States of America
Britney Everett		193	United States of America
Samuel McCain		194	United States of America
Vance Jones		195	United States of America
Alana Walsh		196	United States of America
Kevin Feeney		197	United States of America
Donald OConnell		198	United States of America
Douglas Grant		199	United States of America
Jennifer Whalen		200	United States of America
Michael Hartstein	201	Canada
Pat Fay			202	Canada
Susan Mavris		203	United Kingdom
Hermann Baer		204	Germany
Shelley Higgins		205	United States of America
William Gietz		206	United States of America

Practice Online


HR database model

Query Visualization:

Duration:

Query visualization of Display the full name of employee with ID and present country where (s)he is working - Duration

Rows:

Query visualization of Display the full name of employee with ID and present country where (s)he is working - Rows

Cost:

Query visualization of Display the full name of employee with ID and present country where (s)he is working - Cost

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

Previous: Write a query in SQL to display the department name and number of employees in each of the department.
Next: SQL UNION Exercises Home

What is the difficulty level of this exercise?



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