How to get right grouping in an SQL query

Asked By 0 points N/A Posted on -
qa-featured

I am currently working on a query however, the results i have been getting are not grouped the way I wanted them to.

I am not very certain as well if the grouping I had in mind is possible.

Can somebody check the codes I am working on below and help me?

What I wanted to do is classify the result by Job_Operation.Job_Operation, and then filter them out after. Is this feasible?

SHARE
Answered By 30 points N/A #84119

How to get right grouping in an SQL query

qa-featured

The GROUP BY statement is used in conjunction with the aggregate (like sum(), count() and etc.) functions to group the result-set by one or more columns. If you would try to use aggregate functions without any group, the result of would be equal for all rows. The result of the query returns unique value of the group column. Also, you can perform sub group of a group column. The general query goes like this:

SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name

In your case, since you are not using any aggregate functions, you don't need to have a group. What do I think is you want to sort the result of this query. Am I right?

 

Login/Register to Answer

Related Questions