简体   繁体   中英

sql oracle count lower/upper case

I have usernames with upper and lower case: Example:

  • kelly, KellY, KELLY, kELLy, max, james, James, Carl

how to count this values in order to have the amount (count) in this case should be: 4 and not 8

SELECT 
    username,
    COUNT(*)
FROM 
    usertable
GROUP BY 
   username

您可以使用LOWER将所有名称转换为相同的大小写,然后计算DISTINCT值:

 COUNT(DISTINCT LOWER(username))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM