题解 | #考试分数(四)#
考试分数(四)
http://www.nowcoder.com/practice/502fb6e2b1ad4e56aa2e0dd90c6edf3c
思路:我们先来了解一下取整的几个函数
ceil() / ceiling() 向上取整;示例: ceil(1.2) = 2
floor() 向下取整;示例: floor(1.2) = 1
round() 四舍五入
法一:使用round解决:
select job, round(count(id)/2) as start, round((count(id)+1)/2) as end
from grade
group by job
order by job
法二:使用floor+ceiling:
select job, floor((count(job) + 1)/2) as start, ceiling((count(job) + 1)/2) as end
from grade
group by job
order by job
SQL练习 文章被收录于专栏
已完成牛客的SQL练习。接下来是算法的练习