我收到了以下错误:在以下位置上不存在类型“ MAX”:
SELECT
ff.object_id 'RecordId',
ff.ein 'EIN',
taxpayer_name 'Organization Name',
r0."USAddrss_AddrssLn1Txt" 'Address',
r0."USAddrss_CtyNm" 'City',
r0."USAddrss_SttAbbrvtnCd" 'State',
r0."USAddrss_ZIPCd" 'Zip Code',
sj.*
FROM
peerlist pl
LEFT JOIN
filing_filing ff
ON CAST(pl.ein AS varchar) = ff.ein
JOIN
return_part_0 r0
ON ff.object_id = r0.object_id
JOIN
return_skdjrltdorgoffcrtrstkyempl sj
ON ff.object_id = sj.object_id
INNER JOIN
(
SELECT
ff.ein,
MAX(ff.tax_period) 'tax_period'
FROM
filing_filing ff
GROUP BY
ff.ein
) b
ON ff.ein = b.ein
AND ff.tax_period = b.tax_period;
FF.tax_period是一个整数,所以我不确定为什么MAX无法正常工作。
答案 0 :(得分:0)
您需要使用AS
关键字强制转换/分配列名。您还需要在列标识符中使用双引号。
替换
SELECT ff.ein, MAX(ff.tax_period) 'tax_period' FROM
具有:
SELECT ff.ein, MAX(ff.tax_period) AS "tax_period" FROM
在AS
调用之后和max()
之前通知tax_period