1、bshell 和 kshell的区别?
bshell又称bash shell,kshell又称korn shell。他们都是Linux脚本语句与Linux内核交互的。
bash shell在Linux机器上广泛使用,而korn shell在Unix机器上更多采用。
二者初始化数组的语法不一样,而且kshell没办法用tab键补全command。
2、如何计算客户购买周期?
select customer_id,count(*) from customer_tab group by customer_id;
筛选出count=1的:这部分不存在周期问题。
筛选出count>1的:
select customer_id, lead(buy_time,1,null) over(partition by customer_id order by buy_time asc) as next_buy_time, buy_time, datediff(lead(buy_time,1,null) over(partition by customer_id order by buy_time asc),buy_time)as gap from customer_tab;
3、hive的空值关联时候会存在什么问题?
select * from t1 left join t2 on t1.name=t2.name and t1.age=t2.age and t1.gender=t2.gender;
如果t1/t2两张表的关联条件中有空值(null) 那么空值永远不会等于空值(null=null 返回结果为false),同样是出现在两张表的下面这条记录:
name age gender joy null M
这条记录会因为age两边都为空而关联不上导致查询结果直接消失。正确的办法是先对空值进行预处理,统一转化成其他数字/字符。再关联。
select name, case when name is null then 0 else age end new_age, gender from t1;
4、sql中join默认是什么关联?
join默认=inner join;
5、shell如何定义变量?
variable1=‘hello world’ #定义变量需要中间加等号,等号前面的变量不需要加变量符$
echo $variable1 #调用变量需要用美元符号告诉系统这是变量而非命令或者是一般字符
6、shell如何些多条件的if语句?
variable1=1
if [ $variable1 <1 ];then
echo ‘the variable is smaller than 1’
elif [ $variable1 >1 ];then
echo ‘the variable is greater than 1’
else
echo ‘the variable is equal to 1’
fi
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)