Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

HANA Query group by but add values

Hello everyone,

I am trying to write a query in HANA that achieves the following:

So I want to make the Sales_ID unique. At the same time I want to add the Revenue of each Sales_ID.

What I did so far: Selecting Sales_ID and Revenue, group by Sales_ID and sum up the revenue. So far so good. But it doesnt work when I add the field "Product_ID" since there are different values in each row. (so it doesnt group anymore) But I'm good if I just have the Product_ID of the first row of each Sale.

How do I do that?


Former Member
Former Member replied

You could try min(Product_ID).

Besides that, I'd suggest not to discuss the meaning of the term 'first row' in a relational database ...


3 View this answer in context
Not what you were looking for? View more on this topic or Ask a question