题解 | #话题的分布情况#
话题的分布情况
https://www.nowcoder.com/practice/3f0d5c83b48b450888921b6189be288f
select substring_index (subject_set, ',', 1) subject_id1, count(*) cnt from comment_detail where substring_index ((substring_index (subject_set, ',', 2)), ',', -1) = '1002' group by subject_id1 order by subject_id1
题目不难,就是出题人说的不明白。这个题目想要查出第二个话题是'1002'对应的每一行数据的第一个话题的数目,很明显要
group by,然后再排序,这道题目考察的substring_index函数算是少见的函数。这篇文章讲substring_index讲的挺好