sql - 值更改时,regexp_substr 不起作用
问题描述
我想要每个学生的最低和最高分数。下面是示例标记,我希望 uc_min 作为之前的任何内容 / 和 uc_max 作为之后的任何内容 /
下面是我的代码,它不适用于个位数
select distinct regexp_substr(marks,'[^/]+',1,1) uc_min,
regexp_substr(marks,'[^/]+',4,1) uc_max
from std
where student_id = 'YYY'
预期输出:
Sample marks Expected uc_min Expected uc_max
1/100 1 100
20/30 20 30
180/730 180 730
20/200 20 200
解决方案
一个substr/ instr
解决方案,假设有一个"/"
select substr(marks, 1, instr(marks,'/') - 1) as uc_min,
substr(marks, instr(marks,'/') + 1) as uc_max
from std;
推荐阅读
- java - 当 sql 语句没有返回任何行时,resultset.next() 总是返回 true
- keras - keras中二元分类的类不平衡
- ios - 将新单元格插入表格视图时,在所有可见单元格上调用什么?
- c# - 尝试根据表行的最高 ID 更新特定 SQL Server 表列时出错
- python - 在python中使用liblas和laspy读取las文件的问题
- html - Z-index 没有堆叠
- python - 如何在没有导入库的情况下在 python 文件中获取函数定义?
- java - 从android studio中的按钮单击访问url
- javascript - 如何使用 ArrayBuffer/ArrayBufferView 通过 WebSocket 发送字符串和整数的 Javascript 数组?
- android - 更改 TextInputLayout 提示字体