随笔分类 - oracle
摘要:-- oracle分组排序取出每组顺序第一条 select * from ( select row_number() over(partition by user_code order by create_time desc) rn, t.* from your_table t ) where rn
阅读全文
摘要:-- oracle 列转行逗号分隔 select year, listagg(sales_amount, ',') within group (order by sales_amount) as sales_amounts from sales_data group by year
阅读全文
摘要:-- extract只能从date类型中提取年、月、日 -- 年 select extract(year from sysdate) from dual; -- 月 select extract(month from sysdate) from dual; -- 日 select extract(d
阅读全文
摘要:-- oracle生成uuid select sys_guid() from dual; -- 解决乱码 select rawtohex(sys_guid()) from dual;
阅读全文
摘要:分位数是将总体的全部数据按大小顺序排列后,处于各等分位置的变量值。四分位数也称为四分位点,它是将全部数据分成相等的四部分,其中每部分包括25%的数据,处在各分位点的数值就是四分位数。四分位数有三个,第一个四分位数就是通常所说的四分位数,称为下四分位数,第二个四分位数就是中位数,第三个四分位数称为上四
阅读全文
摘要:当前显示 SQL> select * from test; A B C you pig are 通过修改sys.col$表来改变表中列的顺序 SQL> SELECT owner,object_name,object_id FROM ALL_OBJECTS WHERE OBJECT_NAME='TES
阅读全文
摘要:-- 模糊匹配多个关键字 and regexp_like (name, '(刘|王二花)') and regexp_like (name, '刘|王二花') -- 模糊查询匹配多个字段 and instr(dept_code || dept_name, #{deptName}) > 0
阅读全文
摘要:-- 查询倒数第二条 select * from (select row_number() over(order by pay_no desc) rn, t.* from tm_pm_pay t where hospital_code = '0002') where rn = 2
阅读全文
摘要:-- 获取两个日期之间的天数 select trunc(sysdate) - trunc(sysdate) as days from dual; select to_number(to_date('2021-06-10', 'yyyy-MM-dd') - to_date('2021-01-01',
阅读全文
摘要:-- to_date()将INT或VARCHAR类型的日期转换成DATE类型 SELECT to_date('2021-06-16 09:36:39', 'yyyy-MM-dd HH24:mi:ss') FROM dual; -- to_char()将日期类型转换为字符类型 SELECT to_ch
阅读全文
摘要:-- 获取当前系统时间 SELECT sysdate FROM dual; -- 年月日 SELECT to_char(sysdate, 'yyyy-MM-dd') FROM dual; -- 时分秒 SELECT to_char(sysdate, 'HH24:mi:ss') FROM dual;
阅读全文
摘要:-- 查询第一行 -- 不包含排序时 select * from tm_pm_pay where hospital_code = '0002' and rownum = 1 -- 包含排序时 select * from (select * from tm_pm_pay t where hospita
阅读全文