How to group query base on job in oracle?

by elise_daugherty , in category: Third Party Scripts , 25 days ago

How to group query base on job in oracle?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by wilmer.lemke , 24 days ago

@elise_daugherty 

To group a query based on job in Oracle, you can use the GROUP BY clause in your SQL statement. Here is an example query that groups results based on the job title:

1
2
3
SELECT job, COUNT(*) as total
FROM employees
GROUP BY job;


In this query, we are selecting the job title from the employees table and then using the GROUP BY clause to group the results based on the job title. The COUNT(*) function is used to count the total number of employees for each job title.


You can also include other columns in your SELECT statement to retrieve additional information about each job title. Just make sure to include those columns in the GROUP BY clause as well if you want them to be grouped together with the job title.


Remember, the columns that are not included in the GROUP BY clause should be aggregated using functions like COUNT, SUM, AVG, etc. or you will get an error.