MySQL数据库 - 函数(不含聚合函数)的使用

第1关:字符函数

#请在此添加实现代码
########## Begin ##########
SELECT concat(UPPER(SUBSTRING(name,1,1)),LOWER(SUBSTRING(name,2))) Name FROM employee;

########## End ##########

第2关:数学函数

#请在此添加实现代码
########## Begin ##########
update Score set s_score=TRUNCATE(s_score-(round(sqrt((power(4,4)-power(3,3))/power(2,2)),2)),2);
SELECT s_name,s_score from Score
########## End ##########

第3关:日期时间函数和流程控制类函数

#请在此添加实现代码
########## Begin ##########

select year(s_birth) as Year,timestampdiff(YEAR,s_birth,CURDATE()) as "Age" from Student ;

select Course.c_id as 课程号 ,
max(Score.s_score) as 最高分,
min(Score.s_score) as 最低分,
round(AVG(Score.s_score),2) as 平均分,
CONCAT(TRUNCATE(COUNT(s_score >=60 OR null)/COUNT(s_score)*100,2),'%')as 及格率

from Course join Score on Course.c_id=Score.c_id  GROUP by Score.c_id;


########## End ##########

第4关:自定义函数

#请在此添加实现代码
########## Begin ##########
delimiter //
create function fn_three_max(param_1 int,param_2 int,param_3 int) RETURNS int
BEGIN
        DECLARE max_val int DEFAULT 0;
        if param_1 > param_2 then
            set max_val=param_1;
        else
            set max_val=param_2;
        end if;
        if param_3 > max_val then
            set max_val=param_3;
        end if;
        return max_val;
END
//

########## End ##########

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

怎么什么名字都有啊啊啊

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值