[英]Selecting unique entries from a column
I have this table ID | 我有这个表ID | Category |
类别| Subcategory |
子类别|
1 | Books | Comic |
2 | Books | Fiction |
3 | Cars | New |
4 | Books | Non- fiction |
4 | Cars | Second hand |
and I want to select only unique entries from the column 'Category'. 我想只选择“类别”列中的唯一条目。 That is, I want 'Books' and 'Cars' to be selected only once.
也就是说,我希望“书籍”和“汽车”只选择一次。 How can I write a query ??
我怎么写一个查询? Help please.
请帮助。
You mean distinct ? 你的意思是分明吗
SELECT Distinct Category
FROM Table
Or group by 或分组
SELECT Category
FROM Table
GROUP BY Category
Group by enables you to retrieve various aggregates based on your query (such as number of items in category etc...) 分组允许您根据查询检索各种聚合(例如类别中的项目数等...)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.