易截截图软件、单文件、免安装、纯绿色、仅160KB

一个sql问题 - MS-SQL Server / 基础类

数据如下:
ID money1 money2 money3
0900013348 100.0000 100.0000 100.0000
001221213 100.0000 100.0000 10.0000
001111111 100.0000 100.0000 100.0000
001111112 100.0000 100.0000 100.0000
00122222 100.0000 100.0000 100.0000
0900013714 100.0000 100.0000 100.0000
0900013713 100.0000 100.0000 100.0000
0900013713 300.0000 100.0000 100.0000
0900013713 100.0000 100.0000 100.0000
能实现下面的转换吗?
ID total
0900013348 300.0000
001221213 300.0000
001111111 300.0000
001111112 300.0000
00122222 300.0000
0900013714 300.0000
0900013713 1100.0000

谢谢大家帮忙解答一下。


SQL code:
select ID,sum(money1+money2+money3) as [total]
from tb
group by id


二楼正解

二楼正解!没分析透

二楼是正确的,呵呵

引用
SQL codeselect ID,sum(money1+money2+money3)as[total]from tbgroupby id

树哥抢的很厉害。

引用
引用 2 楼 sgtzzc 的回复:
SQL codeselect ID,sum(money1+money2+money3)as[total]from tbgroupby id

树哥抢的很厉害。
up

引用
SQL codeselect ID,sum(money1+money2+money3)as[total]from tbgroupby id


相关问答:

求一SQL - MS-SQL Server / 基础类

表如下
教室ID 座位数 开始时间 结束时间 2009年1月1日 2009年1月2日 2009年1月3日
  101 50 08:00 08:30 30 40 50  
  101 50 09:00 ......

jsp链接sql2000的疑问?



type Exception report


message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jas ......

多表关联查询的 sql写法 - Oracle / 基础和管理

大家好,我最近维护一个项目,100多个表
只能用jdbc直连
遇到了多个表 关联 查询的情况 请大家指教
比如
student(studentid,classid)
class(classid,classname)
class_teacher(classid,teacherid)这个是中间表 ......

求一条SQL - MS-SQL Server / 疑难问题

--drop table #T1
--drop table #T2
create Table #T1(ID int,
QueryID nvarchar(20),
ResultID1 nvarchar(20),
ResultID2 nvarchar(20))
create Table #T2(SortNo int,
QueryID nvarchar(20),
ResultID1 nv ......

sql存储过程时间相减 - MS-SQL Server / 基础类

CREATE PROCEDURE [selectvipcompany] 
@username varchar(50),
@companyname varchar(50),
@endtime varchar(1)
AS
declare @sql varchar(1000)
set @sql=''
if (@username<>null and @username ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号