Question

mysql> select from Staff: I staffNo | fName LName position sex DOB |SA9 Mary Howe Assistant F1970-02-19|9000,00 |B007 SG14 I

1. listing staff first name, position and their manage first names and positions for all male staff. The output header needs to distinguish between staff and manger.

the answer should be like this

staffName | staffPosition |managerName | managerPosition David SupervisorSusan John | Manager | Manager Huang CEO

0 0
Add a comment Improve this question Transcribed image text
Answer #1

you can use the Self join or left join to get the desired view for example the SQL statement would look like

CREATE VIEW AS

SELECT s1.fName staffName,s1.position staffPosition,s2.fName managerName,s2.position managerPosition

FROM Staff s1

LEFT JOIN Staff s2

ON s1.managerNo = s2.staffNo

Here we are creating two instances of the same table and we are matching/joining based on the managerNo from the first table to the staffNo from the second table.

Add a comment
Know the answer?
Add Answer to:
1. listing staff first name, position and their manage first names and positions for all male...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question 3 (a) Identify the notation A B, and write a brief notes about it. [12...

    Question 3 (a) Identify the notation A B, and write a brief notes about it. [12 marks] (b) Do you believe that logical data independence and distribution independence are the backbone for distributed database Explain your position in detail. [13 marks) Question 4 (a) Study the table and show how you can create it from a scratch using MySQL or SQL Server DOB salary branch No staff No Name Name position Sex SL21 John White Manager M SG37 Ann Beach...

  • For the tables given above, write a relational algebra statement to show the names of the...

    For the tables given above, write a relational algebra statement to show the names of the female staffs whose salaries are more than 10000. Use S for selection, P for projection, |X| for join, X for cross product, T for aggregation and grouping, U for union, ^ for interaction, / for division, - for intersection. TT T Arial 3 (12pt) T5 - E S @a's For the tables given above, write one relational algebra statement to show the Branch No...

  • [Relational Algebra] Using the above information, please write relational algebra expressions and display tables to answer...

    [Relational Algebra] Using the above information, please write relational algebra expressions and display tables to answer the following. Do NOT write in SQL code. 1. Select all staff that happen to be female with a salary more than $20,000 2. List all staff that happen to have a salary between $20,000 and $30,000 Branch branch No street city postcode BOOS BOO7 воод 3004 BOOZ 22 Deer Rd London SWI4EH 16 Argyll St Aberdeen A235U 163 Main St Glasgow GII YOX...

  • Assignment Chapter 6 Part - Assignment Chapter 6 Part 2 - Write Queries that: 1. List...

    Assignment Chapter 6 Part - Assignment Chapter 6 Part 2 - Write Queries that: 1. List all Staff first and last names that have a branch number listed the Branch table. 2. Sort the query results from the query above is descending order 3. Join Branch and Staff tables where branch No are equal 4. Execute Left Outer Join for query 3 5. Execute Right Outer Join for query 3. 6. Insert record - 'CR76', 'PL94', '2018-02-28', 'To Big' into...

  • Use only a single SQL statement for each of the following questions 1 Give a listing of all the ssns,first names and the class descriptions of all the classes the students are taking. If there a...

    Use only a single SQL statement for each of the following questions 1 Give a listing of all the ssns,first names and the class descriptions of all the classes the students are taking. If there are no class _descriptions display 'No description is available yet'. (USE NVL) 2 Give a listing of only the lname and the class_code for students who are taking 'Introduction to C programming'. (Inner join) 3 Give a lising of all the class_descriptions and the number...

  • Query 1: Retrieve names of all the projects as well as First and Last name of...

    Query 1: Retrieve names of all the projects as well as First and Last name of managers if they are working on any of these projects. Database: //STEP #1: CREATE TABLE employee ( fname varchar(15) not null, minit varchar(1), lname varchar(15) not null, ssn char(9), bdate date, address varchar(50), sex char, salary decimal(10,2), Super_ssn char(9), dno char(4), primary key (ssn)); CREATE TABLE department ( dname varchar(25) not null, dnumber char(4), Mgr_ssn char(9) not null, Mgr_start_date date, primary key (dnumber)); CREATE...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT