Reputation: 311
I have two columns called quantity and price. Quantity is divided by price. If the result contains decimal, I want the number before the decimal. Or else, the number as it is.
Upvotes: 1
Views: 1400
Reputation: 38335
Also DIV operator can be used (for integer arguments):
with your_data as (
select stack(3, 13,2,8,2,233,2) as(quantity,price)
)
select quantity div price
from your_data d
;
Result:
6
4
116
Upvotes: 0
Reputation: 618
Casting issues?
select cast(quantity / price as bigint)
By the way, I think you may want this: Hive Data Types Manual
Upvotes: 0
Reputation: 1270021
I think you are looking for:
select floor(quantity / price) as output
Upvotes: 1