Airhmatic Operation on Hive

Arithematicoperators :

·       Arithmetic Operators in Hive supports various arithmetic operations on the operands.

·       All return number types.

·        If any of the operands are NULL, then the result is also NULL.

Different arithematic operators are :

Operator

Operand type

Description

A+B

Number type

Results of adding A and B

A-B

Number type

Results of subtracting B from A

A*B

Number type

Results in productof A and B

A/B

Number type

Results in quotient of A and B

A%B

Number type

Results in modulus A and B

A&B

Number type

Results in bitwise  AND of A and B

A|B

Number type

Results in bitwise  OR  of A and B

A^B

Number type

Results in bitwise XOR of A and B

~A

Number type

Results in Bitwise Not.

 

 

CREATE TABLE :

create external table if not exists marks(id int, ds_marksint, m1_marks int, bee_marksint, dld_marksint, stm_marksint) row format delimited fields terminated by '\t';

LOAD DATA INTO TABLE:

load data local inpath 'file:///home/cloudera/marks.txt' overwrite into table marks;

1.Addition operator:

selectds_marks+bee_marks from marks;

2.Subtraction operator.

selectds_marks-bee_marks from marks;;

3.Multiplication operator:

selectds_marks*dld_marks from marks;

5.Division Operator:

selectds_marks/stm_marks from marks;

6.Modulus operator:

selectds_marks%stm_marks from marks;

7.Bitwise AND

selectds_marks&bee_marks from marks;

8.Bitwise OR:

selectds_marks | bee_marks from marks;

9.Bitwise XOR:

selectds_marks ^ bee_marks from marks;

10.Bitwise NOT:

select ~bee_marks from marks;


Comments

Popular posts from this blog

Problem Statement Of Real Estate Use Cases

Problem Statement Of Bank Marketing analysis

Hadoop