以下查询存在一些问题。我在这里使用的子查询在单独运行时运行时没有任何错误。但是,如果我在下面运行整个查询,则会以错误结束。 “编译语句时出错:FAILED:ParseException行13:30无法识别'select''max''附近的输入(''在表达式规范中”
select acct_num from table1
where ind = 'Y'
and b = (select max(yr_mth_num) from table2)
and st_dt = (select cast(max(st_dt) as date) from table2)
答案 0 :(得分:0)
试试这个:
SELECT T1.acct_num
FROM table1 T1
LEFT SEMI JOIN
(SELECT
max(yr_mth_num) as max_yr_mth_num,
cast(max(st_dt) as date) as max_st_dt
FROM table2) T2
ON T1.b = T2.max_yr_mth_num
AND T1.st_dt = T2.max_st_dt
AND T1.ind = 'Y'