1. Write an SQL query to fetch the no. of workers for each department in the descending order.
Answers
Answered by
1
Answer:
#since you haven't specified any name to the table here imma be using table_name as workers
Use:
Select department ,count(*) from workers group by department order by count(*) desc;
#selecting department ,count(*) both to ensure you can find number per department.
Explanation:
- Select command selects the columns to display
- Count(*) here counts the number of workers after they've been grouped in to various departments.
- Group by groups the works by department.
- Order by desc returns descending order.
Similar questions