You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- floor()函数,取整数
-- months_between()函数,获取两个日期之间的月份数
SELECT t.name as 姓名,
floor(months_between(sysdate, to_date(t.birth_date, 'yyyy-mm-dd')) / 12) as 年龄
from orcal_test t
-- rank() over函数,显示并列排名
-- rownum 用于获取前n行数据
select *
from (SELECT t.name as 姓名,
t.birth_date as 出生日期,
rank() over(order by t.birth_date desc) as 排名
from orcal_test t)
where rownum < 4 -- 获取前三行数据