日期:2014-05-18  浏览次数:20424 次

distinct失效。。,急用大家帮一下。。要的结果不返回重复数据
SELECT   distinct   a.Quote_Nclass_ID,   a.Quote_ID,a.Quote_Title,a.Quote_T_Color,a.Quote_T_Type,b.Nquote_Name   from   Quote_News_Table   as   a   ,   Nquote_Table   as   b     where     a.Quote_Class_ID   =   b.Nquote_Q_ID   AND   a.Quote_Class_ID   =   7  


返回的结果是:
Quote_Nclass   quote_Class_ID   Quote_Title       Quote_T_Type         Nquote_Name  

10 8 werwrewer 0 铁
10 8 werwrewer 0 钢
10 8 werwrewer 0 锌/铅
10 9 wrerweer 0 不锈钢
11 7 wrerweer 0 钢
11 7 wrerweer 0 铝


这是正确的结果:(但我加上其它字段)
select   distinct   a.Quote_Nclass_ID   from   Quote_News_Table   as   a   ,   Nquote_Table   as   b     where     a.Quote_Class_ID   =   b.Nquote_Q_ID   AND   a.Quote_Class_ID   =   7  

Quote_Nclass_ID  
10
11
12
13
14
15
16
17

如果加上   a.Quote_ID,a.Quote_Title,a.Quote_T_Color,a.Quote_T_Type,b.Nquote_Name  
查询出来的结果就不正确,有重复。
请问一下。应该怎么修改?


------解决方案--------------------
我想要的效果如这个例子,楼上可能误会的想要效果了。
table表 A B C
1 2 3
1 2 2
2 3 4
2 1 2
-------------
请问你最后要显示的结果是什么?
因为Distinct(A)有1,2;都分别有两条记录
比如1有1,2,3和1,2,2你要显示哪一条呢?