1

询问:

  select distinct (Customer) ,CustomerID from history where Customer != '' and        Customer LIKE 'Ram%';

结果:

      Ramer ram100
      Raman ra45
      Raman ra45
4

2 回答 2

3

尝试使用MAXand group by

 select Customer, MAX(CustomerID) CustomerID
 from   history
 where  Customer != '' AND Customer LIKE 'Ram%'
 GROUP BY Customer 
于 2012-11-26T08:40:20.943 回答
0

如果您还想查看所有客户 ID,请使用group_concat

select customer, group_concat(distinct customerid)
from history
where Customer != '' and Customer like 'Ram%'
group by customer
于 2012-11-26T08:48:34.627 回答