- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我有一个表“电影”,其中一些年份有额外的字符,用空格分隔:array(['I 2018', 'XVII 2016', '1958', 'I 2017'])
.我想得到唯一的一年删除任何非数字的东西。
我使用 mysql 来完成这项工作,使用类似的东西:SUBSTRING_INDEX(SUBSTRING_INDEX(year,' ', 2), ' ',-1)
我在 mysql 中使用的代码是:
select SUBSTRING_INDEX(SUBSTRING_INDEX(year,' ', 2), ' ',-1) as year from movie
我读到 sqlite3 中没有这样的函数,所以尝试像这样使用 substr :
select substr(SUBSTR(year," ",2),' ',-1) from movie;
但答案不是我所期望的。
最佳答案
假设您的字符串模式基于文本和您需要的数字之间的空格你可以试试
您可以尝试将 sustring_index 替换为空间(和修剪)
select trim(replace("I 2018", SUBSTRING_INDEX("I 2018", " ", 1),''))
select trim(replace("I 18", SUBSTRING_INDEX("I 2018", " ", 1),''))
select trim(replace(your_col, SUBSTRING_INDEX(your_col, " ", 1),''))
from your_table
或者如果你的数据库不支持 substring_index 你可以使用 instr()
select trim(substr( "I 2018", instr( "I 2018", ' '), 100)) ;
select trim(substr(your_column, instr( your_column, ' '), 100))
from your_table ;
关于sql - sqlite3 中的 sql 操作 SUBSTRING_INDEX(SUBSTRING_INDEX(year ,' ' , 2), ' ' ,-1) 的替代品是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57840898/
我需要本地化所有可能性: 1年, 2 年,然后……(不超过任何数字)。 1个月, 2 个月,然后……(不超过任何数字)。 在各种语言中,“年”这个词会根据它前面的数字而变化。比如法语: 22 年 =
本文整理了Java中org.joda.time.Years.years()方法的一些代码示例,展示了Years.years()的具体用法。这些代码示例主要来源于Github/Stackoverflow
年.hs: year = year + 1 main = print year 这不是尾递归调用: year = year + 1 year = (year + 1) + 1 year = ((yea
我有一个表,其中包含来自流量计的数据,排列如下: Water.Year May Jun Jul Aug Sep Oct Nov Dec Jan Feb
本文整理了Java中com.meidusa.amoeba.sqljep.function.Year.year()方法的一些代码示例,展示了Year.year()的具体用法。这些代码示例主要来源于Git
我是 Java 新手,希望获得一些有关正在尝试解决的问题的建议。我必须编写一个方法来生成唯一的编号。 因此,以字符串表示的唯一数字将有 10 个字符。 #1. First 2 will represe
谁有权威的答案,哪个性能更好? GROUP BY YEAR(FROM_UNIXTIME(col)) /* or */ GROUP BY EXTRACT(YEAR FROM FROM_U
我从今年过去了 20 年。但目前我希望它显示为年复一年。例如:1992 - 1999 1999 - 2002 2003 - 2015 这是我的代码。 function populatedropdown
我目前能够将 Landsat 图像拆分为 LC80440142014093LGN00.tar.gz 的日期信息, 我把它分成 2014093 .现在我需要将其更改为 Excel 或 Open Offi
我有一些数据想总结一下。我想对所有列进行总结,固定 YEAR 列。即对于一个变量我可以做: df %>% group_by(LG1, YEAR) %>% summarise(Freq = n(
我有一个独特的问题,我根本无法解决。 所以我在 SQL Server 2005 中,我得到了以下要处理的数据: FISCAL_YEAR_START_MONTH INT(财政年度的第一个月) COUNT
我有一些数据想总结一下。我想对所有列进行总结,固定 YEAR 列。即对于一个变量我可以做: df %>% group_by(LG1, YEAR) %>% summarise(Freq = n(
我想从指定年份的表中获取所有数据。但问题是我将日期设置为 DATETIME 类型。 我正在尝试类似的东西: SELECT * FROM table WHERE entrytim
使用日期选择器,年份下拉菜单默认只显示 10 年。用户必须单击最后一年才能添加更多年份。 我们如何将初始范围设置为 100 年,以便用户默认看到一个大列表? function InitDate
我必须将我的数据帧从当前格式转换为新格式(请参阅下面的图像或结构)。我不知道如何才能做到这一点。我想要每个 ID 一年,从 2013 年到 2018 年(所以每个 ID 有 6 行,每年一个)。日期是
在学习了 Hadley 的书并在 SO 上搜索之后,我创建了一个由年和月矩阵组成的热图,颜色根据时间序列变量的百分比变化而变化。热图和我用来获取它的代码如下所示。我还有一些我自己无法解决的问题。 1)
在电子表格上,我有各种谷歌分析 channel (有机、直接、移动、桌面等)的月度报告表。对于每个 channel ,我都有另一列自动计算 Y-o-Y EX 的增长百分比:(A12-A1)/A1。然后
我有几个气象变量的时间序列数据集。时间数据记录在三个单独的列中: 年份(例如 2012) 一年中的第几天(例如 261 代表闰年的 9 月 17 日) 时:分(例如 1610) 有没有一种方法可以合并
YEAR(x) 和 EXTRACT(YEAR FROM x) 在 MySQL 中是否等价? 似乎在我所有的实验中都有,但我不确定是否没有任何边缘情况。 举个例子:这两个查询返回完全相同的结果。但我不确
我读到“将日期字符串转换为mysql日期时间字段”:但这对我没有帮助 所以我想做的是将dat文件读入mysql中的空表。 table CLIMBED(TRIP_ID int,PEAK VARCHAR(
我是一名优秀的程序员,十分优秀!