Skip to content

Instantly share code, notes, and snippets.

@icemancast
Forked from zgulde/joins.md
Created May 11, 2016 15:34
Show Gist options
  • Save icemancast/7ea3f82c899269a117d444f9007a8216 to your computer and use it in GitHub Desktop.
Save icemancast/7ea3f82c899269a117d444f9007a8216 to your computer and use it in GitHub Desktop.
extra join exercises

Employees Database

  1. Using the example in the Associative Table Joins section as a guide, write a query that shows each department along with the name of the current manager for that department.

       Department Name    | Department Manager
      --------------------+--------------------
       Customer Service   | Yuchang Weedman
       Development        | Leon DasSarma
       Finance            | Isamu Legleitner
       Human Resources    | Karsten Sigstam
       Marketing          | Vishwani Minakawa
       Production         | Oscar Ghazalie
       Quality Management | Dung Pesch
       Research           | Hilary Kambil
       Sales              | Hauke Zhang
    
  2. Find the name of all departments currently managed by women.

     Department Name | Manager Name
     ----------------+-----------------
     Development     | Leon DasSarma
     Finance         | Isamu Legleitner
     Human Resources | Karsetn Sigstam
     Research        | Hilary Kambil
    
  3. Find the current titles of employees currently working in the Customer Service department.

     Title              | Count
     -------------------+------
     Assistant Engineer |    68
     Engineer           |   627
     Manager            |     1
     Senior Engineer    |  1790
     Senior Staff       | 11268
     Staff              |  3574
     Technique Leader   |   241
    
  4. Find the current salary of all current managers.

     Department Name    | Name              | Salary
     -------------------+-------------------+-------
     Customer Service   | Yuchang Weedman   |  58745
     Development        | Leon DasSarma     |  74510
     Finance            | Isamu Legleitner  |  83457
     Human Resources    | Karsten Sigstam   |  65400
     Marketing          | Vishwani Minakawa | 106491
     Production         | Oscar Ghazalie    |  56654
     Quality Management | Dung Pesch        |  72876
     Research           | Hilary Kambil     |  79393
     Sales              | Hauke Zhang       | 101987
    

Bonus Find the names of all current employees, their department name, and their current manager's name.

    240,124 Rows

    Employee Name | Department Name  |  Manager Name
    --------------|------------------|-----------------
     Huan Lortz   | Customer Service | Yuchang Weedman

     .....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment