MySQL Forums
Forum List  »  General

Re: In Mysql, How can I get the result which like grouping_id() in oracle
Posted by: ZhanMeng Lv
Date: April 04, 2016 07:01PM

CONCAT(ISNULL(year)) is used to connect the grouping result just as in oracle.For example, grouping_id(A1,A2,A2) equals seven which means the result is 111 in binary and grouping_id(A1,A2,A2) equals three which means the result is 011 in binary.
So I used CONCAT(ISNULL(A1),ISNULL(A2),ISNULL(A3)) to connect the one or zero which can let me get the result such as 111,011,001,000.
Then I used conv(X,2,10) to convert the connect result to decimal.
But if the group column contains null value, the result is wrong.Because IsNull() returns unexpectd value for me.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.