"select mat.material_no,mat.material_name_eng,mat.spec1,mat.spec2,
mat.spec3,mat.spec4,mat.spec5,mat.spec6,mat.spec7, mat.spec8,mat.latest_update
from material mat
inner join inv_bal inv on mat.material_no=inv.material_no
where mat.material_no like '1%' and mat.latest_update > '2010-01-01'
and mat.user_in_charge <> '780' and mat.user_in_charge <>'239' "
如果用DISTINCT刪除material_no的重複項?
------解决方案--------------------
select DISTINCT 。。。。。。。
------解决方案--------------------
select distinct mat.material_no,mat.material_name_eng,mat.spec1,mat.spec2,
mat.spec3,mat.spec4,mat.spec5,mat.spec6,mat.spec7, mat.spec8,mat.latest_update
from material mat
inner join inv_bal inv on mat.material_no=inv.material_no
where mat.material_no like '1%' and mat.latest_update > '2010-01-01'
and mat.user_in_charge <> '780' and mat.user_in_charge <>'239'
------解决方案--------------------
有无主键?
------解决方案--------------------
DISTINCT刪除material_no的重複項,你只是想刪除material_no的重複項?还有你检查出来的结果用这DISTINCT也没用,它是删除重复数据,不会是单独一个column的,你用你的查询语句作为一个临时表,然后再用相应的条件过滤就可以了,还有你的问题太笼统,只能给你这点意见
------解决方案--------------------
select mat.material_no,mat.material_name_eng,mat.spec1,mat.spec2,
mat.spec3,mat.spec4,mat.spec5,mat.spec6,mat.spec7, mat.spec8,mat.latest_update
from material mat
inner join inv_bal inv on mat.material_no=inv.material_no
where mat.material_no like '1%' and mat.latest_update > '2010-01-01'
and mat.user_in_charge <> '780' and mat.user_in_charge <>'239'
and not exists(select 1 from material where material_no=mat.material_no and latest_update>mat.latest_update)