我想找到“rsp_ver”以 2.0 或更高版本而不是 1.0 开头的情况。我想我可以在 where 子句中使用条件来找出子查询找到的 rsp_ver 代码超过“1.0”的 ID:
select
trim(INS.fst_name) || ' ' || Trim(INS.lst_name) as name,
IDS.rin,
RSP.unit_id,
RSP.indv_id,
RSP.rsp_id,
RSP.rsp_sqnm,
RSP.rsp_ver,
cast(RSP.post_ts as char(16)) as Post,
RSP.post_audit_id
from
dhsdb2.wvs_rsp RSP
join dhsdb2.indv_name_srch INS on RSP.indv_id = INS.indv_id
join dhsdb2.indv_demg_srch IDS on RSP.indv_id = IDS.indv_id
where
RSP.indv_id in
(select
SRSP.indv_id
from
dhsdb2.wvs_rsp SRSP
where
SRSP.indv_id = RSP.indv_id and
SRSP.rsp_ver > '1.0')
and rsp.clse_ts is null
order by
RSP.rsp_ver;
这当然行不通。然后我想我需要那个内部查询来拥有 min 函数,但我跑了 int