用oracle多张表联合查询过滤重复数据不能用distinct返回集合
我用select*fromtt_wip_engineewheree.tt_wip_engine_idin(selectmin(w.tt_wip_engine_id)fro...
我用select * from tt_wip_engine e where e.tt_wip_engine_id in (select min(w.tt_wip_engine_id) from tt_wip_engine w group by w.engine_no)单表这样是可以的但是select * from tt_wip_engine e left join tt_wip_engine_fault on e.tt_wip_engine_id=f.tt_wip_engine_id where e.tt_wip_engine_id in (select min(w.tt_wip_engine_id) from tt_wip_engine w group by w.engine_no)这样就不行了 求解决
展开
2个回答
展开全部
SELECT *
FROM (SELECT *
FROM TT_WIP_ENGINE E
LEFT JOIN TT_WIP_ENGINE_FAULT F
ON E.TT_WIP_ENGINE_ID = F.TT_WIP_ENGINE_ID) TMP
WHERE TMP.TT_WIP_ENGINE_ID IN
(SELECT MIN(W.TT_WIP_ENGINE_ID)
FROM TT_WIP_ENGINE W
GROUP BY W.ENGINE_NO))
FROM (SELECT *
FROM TT_WIP_ENGINE E
LEFT JOIN TT_WIP_ENGINE_FAULT F
ON E.TT_WIP_ENGINE_ID = F.TT_WIP_ENGINE_ID) TMP
WHERE TMP.TT_WIP_ENGINE_ID IN
(SELECT MIN(W.TT_WIP_ENGINE_ID)
FROM TT_WIP_ENGINE W
GROUP BY W.ENGINE_NO))
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询