Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SQL问题需要在一列中添加值,并在另一列中添加列后删除重复项_Sql - Fatal编程技术网

SQL问题需要在一列中添加值,并在另一列中添加列后删除重复项

SQL问题需要在一列中添加值,并在另一列中添加列后删除重复项,sql,Sql,我想根据删除另一列中的重复项添加列值 需要如下所示的数据: 这称为“聚合”。你可以这样做: select name, max(date) as date, -- MAX() gets the max value from the group sum(expense) as expense -- SUM() adds up all the values of the group from t group by name 这就是所谓的“聚合”。你可以这样做: select name

我想根据删除另一列中的重复项添加列值

需要如下所示的数据:

这称为“聚合”。你可以这样做:

select
  name,
  max(date) as date, -- MAX() gets the max value from the group
  sum(expense) as expense -- SUM() adds up all the values of the group
from t
group by name
这就是所谓的“聚合”。你可以这样做:

select
  name,
  max(date) as date, -- MAX() gets the max value from the group
  sum(expense) as expense -- SUM() adds up all the values of the group
from t
group by name