redshift Extract 数据类型的替代方案是什么

Whats the alternative for redshift Extract datatype

Azure 数据仓库中 Extract 的替代方案是什么,我们现在正在使用 datepart,但它不适用于 from,那么 extract 的直接替代方案是什么?

是的,相当于Redshift的EXTRACT is DATEPART, as listed in the supported T-SQL functions of Azure DWH

DATEPART ( datepart , date )

例如RedShift 查询

select salesid, extract(week from saletime) as weeknum
from sales 
where pricepaid > 9999 
order by 2;

在 T-SQL 中相当于

select salesid, DATEPART(ww, saletime) as weeknum
from sales 
where pricepaid > 9999 
order by 2;

DATEPART 不使用 FROM 而是一个具有 2 个参数的函数 - 第一个是 PART,第二个是要应用该函数的 Date/Time。