在Alma統計分析中,除了原有的類號欄位外,也是可以自定義欄位公式來抓取資料的
適用情境:
一、不使用Chinese Classifications(Taiwan)
二、要抓取的類號包含小數點後面內容,如978.356,需要987.3
三、任一分類法都可以用
四、不受特藏影響,如BK 008.543,只抓008.54
使用欄位:
"Holding Details"."852 MARC"
使用方法:
齒輪→編輯公式,並將下面語法貼上後點選確定即可
語法:抓3碼為例
CASE WHEN (LOCATE('$$h',("Holding Details"."852 MARC"))=0)
THEN
NULL
ELSE
(
CASE WHEN (LOCATE('$$',(SUBSTRING( ("Holding Details"."852 MARC") FROM (LOCATE('$$h',("Holding Details"."852 MARC"))+3) FOR (LENGTH("Holding Details"."852 MARC") - (LOCATE('$$h',("Holding Details"."852 MARC"))+3) +1) )))=0)
THEN
(LEFT((TRIM(BOTH ' ' FROM (SUBSTRING( ("Holding Details"."852 MARC") FROM (LOCATE('$$h',("Holding Details"."852 MARC"))+3) FOR (LENGTH("Holding Details"."852 MARC") - (LOCATE('$$h',("Holding Details"."852 MARC"))+3) +1) )))),3))
ELSE
(LEFT((TRIM(BOTH ' ' FROM (SUBSTRING( (SUBSTRING( ("Holding Details"."852 MARC") FROM (LOCATE('$$h',("Holding Details"."852 MARC"))+3) FOR (LENGTH("Holding Details"."852 MARC") - (LOCATE('$$h',("Holding Details"."852 MARC"))+3) +1) )) FROM 1 FOR ((LOCATE('$$',(SUBSTRING( ("Holding Details"."852 MARC") FROM (LOCATE('$$h',("Holding Details"."852 MARC"))+3) FOR (LENGTH("Holding Details"."852 MARC") - (LOCATE('$$h',("Holding Details"."852 MARC"))+3) +1) ))))-1))))),3))
END
)
END
語法說明:
1. LOCATE('$$h',("Holding Details"."852 MARC")):找852 MARC中「$$h」在第幾個位置,如果有找到會回傳起始位置;若沒找到就返回0
2. (LOCATE('$$',(SUBSTRING( ("Holding Details"."852 MARC") FROM (LOCATE('$$h',("Holding Details"."852 MARC"))+3) FOR (LENGTH("Holding Details"."852 MARC") - (LOCATE('$$h',("Holding Details"."852 MARC"))+3) +1) )))=0):確認「$$h」後面是否還有「$$」
3. (LEFT((TRIM(BOTH ' ' FROM (SUBSTRING( ("Holding Details"."852 MARC") FROM (LOCATE('$$h',("Holding Details"."852 MARC"))+3) FOR (LENGTH("Holding Details"."852 MARC") - (LOCATE('$$h',("Holding Details"."852 MARC"))+3) +1) )))),3)):從$$h後面開始取內容到最後,再去頭尾空白,再取3碼
4. (LEFT((TRIM(BOTH ' ' FROM (SUBSTRING( (SUBSTRING( ("Holding Details"."852 MARC") FROM (LOCATE('$$h',("Holding Details"."852 MARC"))+3) FOR (LENGTH("Holding Details"."852 MARC") - (LOCATE('$$h',("Holding Details"."852 MARC"))+3) +1) )) FROM 1 FOR ((LOCATE('$$',(SUBSTRING( ("Holding Details"."852 MARC") FROM (LOCATE('$$h',("Holding Details"."852 MARC"))+3) FOR (LENGTH("Holding Details"."852 MARC") - (LOCATE('$$h',("Holding Details"."852 MARC"))+3) +1) ))))-1))))),3)):從$$h後面開始取內容到$$前,再去頭尾空白,再取3碼
5. CASE WHEN…THEN…ELSE…END:是條件判斷,當符合狀況一就會處理THEN的部份,若不符合狀況一就進入ELSE的部份
改抓1碼或2碼:改紅色數字部份
*改成LEFT( … ,1):等於抓1碼,也就是「9」,等於900-999
*改成LEFT( … ,2):等於抓2碼,也就是「97」,等於970-979