Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
好的,所以我有一个字符串作为列存储在数据库中,为了简单起见,假设数据库看起来像这样:
id - string 0 string1 1 string1 2 string1 3 string2 4 string1 5 string3
我将如何编写一个查询来列出字符串列中的每个字符串以及有多少行具有该值。例如在这种情况下,它看起来像这样:
string - count string1 4 string2 1 string3 1
谢谢您的帮助
SELECT string, count(*) as count FROM TABLE GROUP BY string
SELECT string, Count(*) as Count FROM myTable GROUP BY string
顺便说一句,你所展示的是一个表而不是一个数据库。此外,string对于一列来说,这是一个非常糟糕的名称。
string