Sql Query Language using subquery [closed]
up vote
-5
down vote
favorite
How do I write a query in sql to update the salary of each instructor to 10,000 times the number of course sections they have taught given the schema below?
Here is the schema of the database:
sql
New contributor
closed as too broad by Gordon Linoff, David, rsjaffe, johnny 5, gnat Nov 10 at 19:34
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
up vote
-5
down vote
favorite
How do I write a query in sql to update the salary of each instructor to 10,000 times the number of course sections they have taught given the schema below?
Here is the schema of the database:
sql
New contributor
closed as too broad by Gordon Linoff, David, rsjaffe, johnny 5, gnat Nov 10 at 19:34
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
1
Great idea, just do it. But 1 million times would be even better ;-)
– dnoeth
Nov 10 at 16:21
add a comment |
up vote
-5
down vote
favorite
up vote
-5
down vote
favorite
How do I write a query in sql to update the salary of each instructor to 10,000 times the number of course sections they have taught given the schema below?
Here is the schema of the database:
sql
New contributor
How do I write a query in sql to update the salary of each instructor to 10,000 times the number of course sections they have taught given the schema below?
Here is the schema of the database:
sql
sql
New contributor
New contributor
edited Nov 11 at 4:43
New contributor
asked Nov 10 at 16:18
Fred Adrah
32
32
New contributor
New contributor
closed as too broad by Gordon Linoff, David, rsjaffe, johnny 5, gnat Nov 10 at 19:34
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as too broad by Gordon Linoff, David, rsjaffe, johnny 5, gnat Nov 10 at 19:34
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
1
Great idea, just do it. But 1 million times would be even better ;-)
– dnoeth
Nov 10 at 16:21
add a comment |
1
Great idea, just do it. But 1 million times would be even better ;-)
– dnoeth
Nov 10 at 16:21
1
1
Great idea, just do it. But 1 million times would be even better ;-)
– dnoeth
Nov 10 at 16:21
Great idea, just do it. But 1 million times would be even better ;-)
– dnoeth
Nov 10 at 16:21
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
Query:
UPDATE instructor
SET salary = 10000 *
(SELECT COUNT(*) FROM section s
JOIN teaches t ON s.sec_id = t.sec_id
JOIN instructor i ON t.id = i.id
WHERE i.id = instructor.id);
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Query:
UPDATE instructor
SET salary = 10000 *
(SELECT COUNT(*) FROM section s
JOIN teaches t ON s.sec_id = t.sec_id
JOIN instructor i ON t.id = i.id
WHERE i.id = instructor.id);
add a comment |
up vote
0
down vote
accepted
Query:
UPDATE instructor
SET salary = 10000 *
(SELECT COUNT(*) FROM section s
JOIN teaches t ON s.sec_id = t.sec_id
JOIN instructor i ON t.id = i.id
WHERE i.id = instructor.id);
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Query:
UPDATE instructor
SET salary = 10000 *
(SELECT COUNT(*) FROM section s
JOIN teaches t ON s.sec_id = t.sec_id
JOIN instructor i ON t.id = i.id
WHERE i.id = instructor.id);
Query:
UPDATE instructor
SET salary = 10000 *
(SELECT COUNT(*) FROM section s
JOIN teaches t ON s.sec_id = t.sec_id
JOIN instructor i ON t.id = i.id
WHERE i.id = instructor.id);
answered Nov 10 at 17:43
Antonio Alvarez
10214
10214
add a comment |
add a comment |
1
Great idea, just do it. But 1 million times would be even better ;-)
– dnoeth
Nov 10 at 16:21