Chapter 6 (Query Questions) Flashcards

Basic SQL. (Use tables in slides 12-13 as reference.)

1
Q

Give all employees in the ‘Research’ department a 10% raise in salary.

A

UPDATE EMPLOYEE
SET SALARY = SALARY *1.1
WHERE DNO IN (SELECT DNUMBER FROM DEPARTMENT WHERE DNAME=’Research’);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Change the location and controlling department number of project number 10 to ‘Bellaire’ and 5, respectively.

A

UPDATE PROJECT
SET PLOCATION = ‘Bellaire’, DNUM = 5
WHERE PNUMBER=10;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Show the resulting salaries if every employee working on
the ‘ProductX’ project is given a 10 percent raise.

A

SELECT E.Fname, E.Lname, 1.1 * E.Salary AS Increased_sal
FROM EMPLOYEE AS E, WORKS_ON AS W, PROJECT AS P
WHERE E.Ssn=W.Essn AND W.Pno=P.Pnumber AND
P.Pname=‘ProductX’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Query 8. For each employee, retrieve the employee’s first and last name and the first and last name of his or her immediate supervisor.

A

SELECT E.Fname, E.Lname, S.Fname, S.Lname
FROM EMPLOYEE AS E, EMPLOYEE AS S
WHERE E.Super_ssn=S.Ssn;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly