Home > database >  Count (distinct) group by usage
Count (distinct) group by usage

Time:09-19

The select ORDER_ITEM_ID, ask_id cust_order_id,
Count (distinct cust_order_id) from order_item group by cust_order_id
1, first of all, this statement is no syntax errors, can find out the result, are often use count () field must be at the back of the group by,
2, the return of the result is what mean? Look not to understand, how the main value of a field in front of a few take?

CodePudding user response:

Can be detected as a result, it should be do query in MySQL, Oracle does not support the,


The original poster can baidu sql_mode, only_full_group_by these two key words,

CodePudding user response:

reference 1st floor selling fruit net reply:
can be detected as a result, it should be doing in MySQL queries, Oracle does not support the,


The original poster can baidu sql_mode, only_full_group_by these two key words,

Yes, I am a mysql, found out what the results mean, in front of the two fields ORDER_ITEM_ID, ask_id corresponding values are not the same, is how of,
That means cust_order_id values are the same, ORDER_ITEM_ID, ask_id values corresponding to different, it is how to extract?

CodePudding user response:

That means cust_order_id values are the same, ORDER_ITEM_ID, ask_id values corresponding to different, it is how to extract?

After the two values, the value of the first line as, in fact, the value is not stable, the original poster can export to all the data, the reduction in another database, the query again, the data is likely to be different,

So it is not recommended to use this feature,

CodePudding user response:

Are you in front of the table or trying to define your own table

CodePudding user response:

reference 4 floor qq_42574779 response:
this table is in front of you or trying to define your own table
said?
  • Related