Computer Science, asked by Nithyagokulapriya, 1 month ago

Write a query to display the names of the staff who are handling atleast 1 subject, ordered by name in ascending order.
BY SQL join & subquery

Answers

Answered by SwagnikChakraborty
15

Answer:

select  staff_name from subject join staff

on staff.staff_Id=subject.staff_Id

group by staff_name

having count(subject_Id)>0

order by staff_name;

Explanation:

Answered by Rameshjangid
1

Answer:- We need to write a query to display the names of the staffs who are handling at least one subject, ordered by names in ascending order. The query is written:-

select  staff_ name from staff name group

Then write, staff_ Id from subject.staff_ Id group

After that, group by staff_ name

having count(subject- id)>0

order by staff_ name;

If you want to sort the given data by descending order, then you have to use the DESC keyword.

For example,

First SELECT columns FROM table menu

Then ORDER BY column DESC.

Then the SELECT statement in SQL tells the computer to get data from the table you are looking for.

In SQL, the FROM clause specifies which table we want to list.

Now if you want to sort the name column in ascending order, then you would have to use this syntax:-

SELECT * FROM staffs

ORDER BY name;

The (*) character tells the computer to select all of the columns in the table which you are working on.

After this command you can see that, the names are now sorted alphabetically.

You can also sort multiple columns in ascending order in the same command at the same time or in the same table.

And if you want to sort some of the data in ascending order and other data in descending order, then for that you would have to use the ASC and DESC keywords in your program.

To know more about the given topic please go through the following

Link1:- https://brainly.in/question/11828499?

Link2:- https://brainly.in/question/40277231?

#SPJ3

Similar questions