Created
January 4, 2021 02:05
-
-
Save ryuuji/354a39ede6461336baaed6bec0cd7545 to your computer and use it in GitHub Desktop.
出版社記号を取り出す(Google BigQueryのDML)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 出版社記号を取り出す | |
# ISBN-10を想定 | |
CREATE TEMP FUNCTION | |
stripPublisherID(a STRING) | |
RETURNS STRING | |
LANGUAGE js AS """ | |
if(!a.length==10)return null; | |
if(!a.startsWith('4'))return null; | |
let ln = 0; | |
let part = parseInt(a.substr(1,7)); | |
if(part>=0 && part<=1999999){ | |
ln=2; | |
}else if(part>=2000000 && part<=5999999){ | |
ln=3; | |
}else if(part>=6000000 && part<=6999999){ | |
ln=8; | |
}else if(part>=7000000 && part<=8499999){ | |
ln=4; | |
}else if(part>=8500000 && part<=8999999){ | |
ln=5; | |
}else if(part>=9000000 && part<=9499999){ | |
ln=6; | |
}else if(part>=9500000 && part<=9999999){ | |
ln=7; | |
} | |
return a.substr(1,ln); | |
"""; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment