如何编写java逻辑到sql查询

时间:2016-03-13 08:05:54

标签: sql select aggregate-functions

我有一个数据库查询select * from student;

学生表中有以下数据。

language     countries      know    dontknow    members
--------      -------        ----    -------    --------
english          USA        50000   20000       500000
french         FRANCE       80000   30000       800000
jerman        German        30000   40000       900000
italian        Italy        20000   50000       700000
english          USA        50000   20000       500000
french         FRANCE       80000   30000       800000
jerman        German        30000   40000       900000
italian        Italy        20000   50000       700000

输出将是这样的:

country     know(sum)       dontknow(sum)   members(sum)
-------     --------        -------------   ------------
UsA         100000          40000       1000000
FRANCE      160000          60000       1600000
German      60000           80000       1800000
Italy       40000           100000      1400000

1 个答案:

答案 0 :(得分:1)

您需要按国家/地区分组并汇总相关列:

6