Sql Query Language using subquery [closed] - sql

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
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:

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);

Related

Write Oracle SQL queries [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 10 months ago.
Improve this question
how to rank each country based on number of people in SQL.
Try
SELECT * FROM (
SELECT country, count(people) as count FROM your_table GROUP BY country
) ORDER BY count DESC

Find sum from 2 tables and write code in php [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
This is the query image:
This result should appear as follows:
This is my query: select id, name, total where student.id= marks.sutdent_id
You should group on the student id and name and sum the marks:
SELECT s.id, s.name, SUM(e.marks) AS total
FROM student s
JOIN exam e ON s.id = e.stud_id
GROUP BY s.id, s.name

SQL Join...Issue with joins [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I need help regarding SQL joins, i am trying join two tables as shown in below images
I guess you can try the below query to get the desired result -
SELECT CASE WHEN CT.partner2 IS NULL
THEN C.partner_id
ELSE CT.partner1
END Partner1,
CT.partner2,
C.Type,
C.Company_name,
C.First_name,
CT.city,
CT.Phone,
CT.Email
FROM CUSTOMER C
LEFT JOIN CONTACTS CT ON C.partner_id = CT.partner2

SQL returns null data [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I need to remove values ​​that has null result (second row)
Your query that you posted uses correlated sub queries to get the results that could easily achieved with a left join. Changing that left join into an inner join will get rid of the nulls as long as you do not have nulls in the name column of the emp table.
select e.empno,e.ename,mngr.name
from emp e
inner join emp mngr on e.mgr=mngr.empno

How can I get the Unit Number to be displayed in place of the "ID" [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
How can I write a SQL query that will replace the "ComputerID" and "PartID" with the "UnitNumber". The ComputerID's and PartID's are in the same column under InventoryID. The InventoryID's are unique but the UnitNumber (sticker label/name) doesn't have this requirement.
Here are the tables and how they relate.
Let's call your tables Object and Inventory
If you use a couple of joins then this should work:
select o.ObjectID as ObjectID, a.UnitNumber as Computer, b.UnitNumber as Part,
o.InputID from Object o
join Inventory a on a.InventoryID=o.CombputerID
join Inventory b on b.InventoryID=o.PartID