T
T
thelastride2020-09-16 09:25:21
Oracle
thelastride, 2020-09-16 09:25:21

Sort by one column. How to avoid adding others to GROUP BY?

Greetings.

Faced one problem, a sorting problem. I have view A, its logic looks like this:

select id as acc_id, name as acc_name, sum(numberValue) as acc_value from accounts group by id, name


There is a view B:
select acc_id, acc_name, acc_value from views.A group by acc_id


But in the second one, I need grouping only by acc_id, but I get an error that says that I should add other columns (acc_name, acc_value) to the grouping, which breaks the logic that should be in the result.

Tell me how to implement grouping by only one column, having similar views.

(the structure and logic of the views are invented and have nothing to do with the real ones)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Matveev, 2020-09-19
@ematveev

so why group by name if id already provides uniqueness? try grouping by id only

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question