我有两个表,其中日期字段填充有每月数据。日期字段之一使用月初,一个使用月末。我正在使用具有两个字段的INNER JOIN,但无法获取日期格式:
SELECT * FROM crd_own.ml_corp_index_data_monthly tb1
INNER JOIN pm_own.esg_credit_factors tb2
ON tb1.TICKER = tb2.ISSUER_TICKER
AND to_date('tbl.DATADATE', 'yyyy/mm') =to_date('tb2.AS_OF_DATE', 'yyyy/mm')
答案 0 :(得分:1)
使用Oracle,您可以trunc
将两个日期都设为月份,然后进行比较。请不要那样,正如@xQbert所评论的那样,您不想将日期括在引号中,因为这会阻止Oracle正确解释日期。
SELECT *
FROM
crd_own.ml_corp_index_data_monthly tb1
INNER JOIN pm_own.esg_credit_factors tb2
ON tb1.TICKER = tb2.ISSUER_TICKER
AND trunc(tb1.DATADATE, 'month') = trunc(tb2.AS_OF_DATE, 'month')
答案 1 :(得分:0)
谢谢大家。...这行得通:
module.exports = {
extend: "apostrophe-pieces",
name: "modal",
label: "Modal",
seo: false,
addFields: [
{
name: "_image",
type: "joinByOne",
withType: "apostrophe-image",
label: "Pick an image",
required: true,
idField: "_id",
filters: {
// Thought maybe not having a projection was an issue. didn't help
projection: {
attachment: 1
}
}
}
]
};