我有这样的数据我见过函数和子串和LEFT,右也 但它不符合我的目的
declare @t table (val varchar(50))
INSERT INTO @t(val)values ('E-001GHDEM120ENDORSEMENT'),
('E-001GHDEM120Renewal'),
('E-001GHDEM120Adjustment'),
('E-001GHDEM120ENDORSEMENT')
select * from @t
输出
ENDORSEMENT
Renewal
Adjustment
ENDORSEMENT
我需要在where条件中使用该语句来过滤记录
答案 0 :(得分:0)
试试这个。从你的例子来看,这就是我的理解。
select right(val,patindex('%[0-9]%', reverse(val))-1)
from @t
答案 1 :(得分:0)
尝试此选择
library(dplyr)
prod <- c('P1','P2','P3')
level <- c('L1','L2','L3')
part <- c('p1','p2','p3','p4','p5')
axis_x <- list(L1 = list('Ordering' = 'id'),
L2 = list('Ordering' = 'id', 'Part name' = 'part'),
L3 = list('Ordering' = 'id', 'Part name' = 'part'))
# Data for module 1
set.seed(123)
module1_df <- data.frame(prod = sample(prod,300, replace = T),
level = sample(level, 300, replace = T),
part = sample(part, 300, replace = T),
value = rnorm(300))
module1_df <- module1_df %>%
group_by(prod) %>%
mutate(id = 1:n()) %>%
arrange(prod, id)
# Data for module 2
set.seed(321)
module2_df <- data.frame(prod = sample(prod,300, replace = T),
level = sample(level, 300, replace = T),
part = sample(part, 300, replace = T),
value = rnorm(300))
module2_df <- module2_df %>%
group_by(prod) %>%
mutate(id = 1:n()) %>%
arrange(prod, id)