Home > database >  Use a hive of built-in functions for long data operation
Use a hive of built-in functions for long data operation

Time:09-19

1. Demand
Statistics of the emergence of a day, every month, such as the following two number
0100010101000101010100101010101
1101010101010101010100101010100
The number of a total of 31, each representing a month one day, such as telecom's number one day use flow record is set to 1, not 0

Now is to want to put the two Numbers together, I need the figures are the two logo on the same day 1 is set to 1, the two are set to 1, the results had better not have scientific count, I want the result is that 1101010101010101010100101010101, -- -- -- -- -- -- -- -- --
bitwise or operations
2. Process
Because digital length 31, ordinary digital type can't save so long data, so build table, I use the string data storage for the type line,

On or operation, I need to convert a string type to integer, I use bigint to store, but the problem is that I am a cast function in the process of conversion, found the beginning of 0 string to grasp in after, can't keep at the beginning of 0, so the results is not correct,

Help leaders to help me after using the built-in functions to transform the type string data retention of 0, and it also can carry out calculations,

CodePudding user response:

Ok, give a bosses, has been solved, I just only do the query, and found that the data is not correct, so for help,
Now I find the string of half open, the transformed data type does not affect the operation
  • Related