1
select distinct (Customer) ,CustomerID from history where Customer != '' and Customer LIKE 'Ram%';
結果:
Ramer ram100
Raman ra45
Raman ra45
select distinct (Customer) ,CustomerID from history where Customer != '' and Customer LIKE 'Ram%';
結果:
Ramer ram100
Raman ra45
Raman ra45
嘗試使用MAX
和group by
。
select Customer, MAX(CustomerID) CustomerID
from history
where Customer != '' AND Customer LIKE 'Ram%'
GROUP BY Customer
如果你想看到所有客戶ID以及使用group_concat
select customer, group_concat(distinct customerid)
from history
where Customer != '' and Customer like 'Ram%'
group by customer
@kurya:的customerID也是字符串數據類型。 – karthik
沒關係。順便說一句,爲了更清楚一點,你可以添加樣本記錄與預期的結果。 –
@kurya:明白了,謝謝。 – karthik