思考:需要在字段:mje_fore_qty、mjy_fore_qty找出最大值和最小值
解决:hive中是有max()和min()函数的
但是,那是用在求某一列字段的最大值/最小值的,很明显在这里是不能派上用场的~
那么,既然现在是多个字段,那能不能把它们塞到一个字段去呢?然后再用上最大值/最小值方法
嗯哼,哦豁,儿豁,这个思路好像可以(=_=)
这不就是数组的概念嘛
,sort_array(array(CAST(t1.MJE_FORE_QTY as int),CAST(t2.MJY_FORE_QTY as int))) array ,sort_array(array(CAST(t1.MJE_FORE_QTY as int),CAST(t2.MJY_FORE_QTY as int)))[0] min_val,sort_array(array(CAST(t1.MJE_FORE_QTY as int),CAST(t2.MJY_FORE_QTY as int)))[1] max_val