![](/img/trans.png)
[英]How to extract day/month/year etc from varchar date field, using Presto?
[英]How to extract the year from a numeric string using Sql/Presto?
您好,我正在通過 Presto 使用 SQL,我正在嘗試從下面的數字字符串中提取年份以及如何對字符串進行分組,以便我可以按年而不是按月提取。 該字符串不存儲為日期,而是存儲為數字。 以下為 2019 年 1 月。
201901
只需除以 100:
select floor(num / 100) as year
注意:Presto 做 integer 划分。 因此,如果“數字”值是 integer,您可以使用:
select num / 100 as year
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.