2012-11-26 148 views

回答

3

嘗試使用MAXgroup by

select Customer, MAX(CustomerID) CustomerID 
from history 
where Customer != '' AND Customer LIKE 'Ram%' 
GROUP BY Customer 
+0

@kurya:的customerID也是字符串數據類型。 – karthik

+0

沒關係。順便說一句,爲了更清楚一點,你可以添加樣本記錄與預期的結果。 –

+0

@kurya:明白了,謝謝。 – karthik

0

如果你想看到所有客戶ID以及使用group_concat

select customer, group_concat(distinct customerid) 
from history 
where Customer != '' and Customer like 'Ram%' 
group by customer 
相關問題