cancel
Showing results for 
Search instead for 
Did you mean: 

Doubt in GROUP By clause

former_member182337
Participant
0 Kudos

Hi All,

I am new to HANA and trying out various sql queries to check the functions of the same. I executed one query and i got the result. The issue is when i "GROUP BY" on the same where condition the result is not coming.

select vbeln, doc_cat, doc_type , val1,val2 , order_qty,trgt_qty from <the model> where doc_cat = 'G' and order_qty <> 0 and trgt_qty <> 0.

For the above select query , i am able to get the output [ 10 rows of data]

 

select vbeln, doc_cat, doc_type ,sum( val1),sum(val2) , sum(order_qty),sum(trgt_qty) from <the model> where doc_cat = 'G' and order_qty <> 0  and trgt_qty <> 0 group by vbeln,doc_cat,doc_type ;



For the above query, the result is blank. I mean, there is no output displayed. Only the columns are displayed. If for the first query the output is displayed then the second query also there has to be an output isnt it?


Can some one help please?



Thanks,

Prem

Accepted Solutions (1)

Accepted Solutions (1)

lbreddemann
Active Contributor
0 Kudos

Your post does not contain information specific enough to see what's possibly wrong here.

As with all problems, reduce this one down to the minimum and let us know your exact steps.

Create a table.

Insert some data.

Build your model on top of that.

Run the simple query.

Run the aggregated query.

Does the issue still occur?

If it doesn't - what's different to your <the model> ?

- Lars

Answers (2)

Answers (2)

former_member182337
Participant
0 Kudos

The query was wrong. Modified it slightly and it works now..Thanks all.

Former Member
0 Kudos

Hello Prem,

are you aware that (when using calculated views within your model) a query against a view executed in the calculation engine could end up in different results than a query against a view executed in the SQL engine?

This could be your underlying issue 🙂

Best regards,

Tobias

former_member182337
Participant
0 Kudos

Hello Lars and Tobias,

Sorry for replying late..Didn't had the internet access.

@Tobias - The query is based on an analytical view but i guess it is something to do with calculate before aggregation or after that is causing this. I am able to see the sales order details in the output but when i use sum for all the measures ( for the same where condition ) the output does not seem to come. Can you please explain the difference between querying on the sql and on the view. may be that could throw some light on this.

@ Lars - I agree. With the information given, nothing much could be answered. I will continue to analyze further and seek help again if required.

@ Tobias & Lars - This may not be a relevant question for this thread but can you explain me the difference between calculation before aggregation option & formula . Pls let me know if i have to create a new thread.

Thanks,

Prem

lbreddemann
Active Contributor
0 Kudos

Yep, a new thread would be a good idea.