select Num,Customer_Name,ETA,Ship_Mode
from tb a
where exists
(select * from tb where Container=a.Container and Customer_Name<>a.Customer_Name and right(rtrim(ltrim(Container)),2)='CY')
from tb a
where exists
(select * from tb where Container=a.Container and Customer_Name<>a.Customer_Name and right(rtrim(ltrim(Container)),2)='CY')
(select Container from tb where right(Ship_Mode,2) = 'CY' group by Container having count(*) > 1)
1.查询某一段日期内(如2008-10-1至2008-10-31)
2.Ship_Mode这个字段中的数据是最后两位数是"CY"的
3.Container这个字段中相同的但Customer_Name中不相同的数据
4.输出数据库中出全部符合以上结果的所有字段的数据数据库名称:Web_Bargain我原来写的语句是这样的:
Select * from (select ID,Num,Factory_Make,Handled,ETD,Amt,Unit,BL,Customer_Name,Container,ETA,Modify_Time from (select count(*) as counts,ID,Num,Factory_Make,Handled,ETD,Amt,Unit,BL,Customer_Name,Container,ETA,Modify_Time from Web_Bargain where Ship_Mode Like '%CY' group by ID,Num,Factory_Make,Handled,ETD,Amt,Unit,BL,Customer_Name,ETA,Container,Modify_Time) as t1 where counts>0 group by ID,Num,Factory_Make,Handled,ETD,Amt,Unit,BL,Customer_Name,Container,ETA,Modify_Time) as t2 where ETA Between #"& Search_Key &"# and #"& Search_Key2 &"#" 但不符合我所要查询的结果。