我有这个简单的Bean类:
public class Book {
public Book(Map<String, String> attribute) {
super();
this.attribute = attribute;
}
//key is isbn, val is author
private Map<String, String> attribute;
public Map<String, String> getAttribute() {
return attribute;
}
public void setAttribute(Map<String, String> attribute) {
this.attribute = attribute;
}
}
Run Code Online (Sandbox Code Playgroud)
在我的主要课程中,我向List添加了一些信息:
Map<String, String> book1Details = new HashMap<String, String>();
book1Details.put("1234", "author1");
book1Details.put("5678", "author2");
Book book1 = new Book(book1Details);
Map<String, String> book2Details = new HashMap<String, String>();
book2Details.put("1234", "author2");
Book book2 = new Book(book2Details);
List<Book> books = new ArrayList<Book>(); …Run Code Online (Sandbox Code Playgroud) 我有以下表格:
topic_id(unique) forum_id forum_views
1002 1885 5
1003 1893 2
1004 1885 3
1005 1892 6
Run Code Online (Sandbox Code Playgroud)
我怎么能得到这样的输出:(独特的forum_id与上面的论坛总观点)
forum_id forum_views
1885 8
1893 2
1892 6
Run Code Online (Sandbox Code Playgroud)
任何帮助都是赞赏的.
这就是我想要的:
从table_name中选择distinct forum_id,sum(topic_views)