select city_std || '/' || stationname as name_std, city_std from station s,
(select (select substr(s.name_std,0, instr(s.name_std, '/')-1) from dual) || '.' ||
(select substr(getxtxx(s.maintainunit),0, instr(getxtxx(s.maintainunit), '供')-1) from dual) as city_std FROM station s where s.stationcode='00000000000001001540')[img]http://dl.iteye.com/upload/attachment/0084/2035/a071f994-976d-302e-a10e-9c991163768d.jpg[/img]
说明:
from station s, 以后为定义一个可复用的city_std查询结果
instr() 查找给点字符的位置
substr() 取子字符串
getxtxx()自定义函数
|| 字符连接
本文介绍了一种使用SQL进行复杂查询的方法,包括如何利用instr()函数查找特定字符的位置、使用substr()函数提取子字符串以及字符串连接操作。通过具体的代码示例展示了如何从stations表中选择城市和站点名称,并构造了一个复杂的查询来获取维护单位的相关信息。
1053

被折叠的 条评论
为什么被折叠?



