字符串专题
作者:互联网
字符串的处理要求多样,这里做积累。
1. 首字母大写:
sql 没有像 python 一样,首字母大写的函数--title() substring(name,2):左起第二个开始取子集力扣1667:
select user_id,concat(upper(left(name,1)),lower(substring(name,2))) as name from Users order by user_id
2. 聚合合并:
一般地,group by 后被单值覆盖,group_concat(... [order by ...]) 聚合后保留多值
力扣1484:
select sell_date,count(distinct product) as num_sold,group_concat(distinct product order by product) as products from Activities group by sell_date
标签:product,专题,group,name,首字母,字符串,order,concat 来源: https://www.cnblogs.com/peitongshi/p/16683715.html