1: EXTRACT()
is an SQL function used to extract a specific part from a date or time value. Its basic syntax is as follows:
EXTRACT ( field FROM source )
where, field
specifies the part to extract source
from and can be one of the following values:
YEAR
:yearsMONTH
:monthDAY
:DayHOUR
: hour (24-hour format)MINUTE
:minuteSECOND
: seconds
source
is a date or time value, which can be a column name, expression, or constant.
For example, if you have a datetime
column and you want to extract the year in that column, you can use the following query:
SELECT EXTRACT(YEAR FROM datetime) AS year FROM mytable;
SELECT
DEBUG_EQUIPMENT_TREND AS 调试台设备利用率 ,
SHAKING_EQUIPMENT_TREND AS 震动台设备设备利用率 ,
STICKERS_EQUIPMENT_TREND AS 电装标贴设备利用率,
DEBUG_EQUIPMENT_FAILURERATE AS 调试台故障率,
SHAKING_EQUIPMENT_FAILURERATE AS 震动台故障率,
STICKER_EQUIPMENT_FAILURERATE AS 电装标贴故障率
FROM BRAIN.DM_EQUIPMENTUTILIZATION_TREND
WHERE EXTRACT(YEAR FROM TO_DATE(STAT_TIME, 'YYYYMM')) = '2023'
This returns a new column year
named containing datetime
the year portion of each date value in the column.