麻烦大家帮忙看看错在哪里了.
同一个表我查找了重复值,然后我想把重复的都显示出来.包括不重复其他字段.就把做了inner join可是出不来结果.
中间红色的查询语句单独执行能出来结果.
请问我哪里错了?是因为用了having吗?
select * from DETAIL as A
inner join (SELECT B.PRODT_ORDER_NO,B.ITEM_CD,B.QTY
FROM DETAIL B
where B.DOCUMENT_YEAR ='2014'
AND B.ITEM_CD LIKE N'MG8%'
AND B.PRODT_ORDER_NO IS NOT NULL
AND B.PRODT_ORDER_NO <> ''
AND B.SL_CD=N'SF01' AND TRNS_TYPE=N'PI'
group by B.PRODT_ORDER_NO ,B.QTY,PRODT_ORDER_NO,B.ITEM_CD
having(count(*))>1
) C
on A.PRODT_ORDER_NO = C.PRODT_ORDER_NO AND A.QTY = C.QTY
我了个去,我自己找到原因了.原来是字段有两个.居然放错字段了.
[ 本帖最后由 dyj545 于 2014-11-20 17:28 编辑 ]