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

sql 查询问题 - .NET技术 / ASP.NET

id name gongzi
1 张三 1000
2 李四 2000
3 张三 2000
4 李四 3000
5 王五 3000


我有这样一个数据库,现在我要sql查询的数据是 张三,李四,王五的 合计的工资。就是把他们的和求出来!

我要的结果是 :
id name gongzi
1 张三 3000
2 李四 5000
3 王五 3000

这样的SQL 怎么写呢?
select * where id=1 and id=2 and id=3

SQL code:
select name,gongzi=sum(gongzi)
from tb
group by name


SQL code:
select [name],sum(gongzi) as gongzi
from gzb
group by [name]


select name,sum(gongzi) from 表 group by name


引用
SQL codeselect[name],sum(gongzi)as gongzifrom gzbgroupby[name]

速度都很快嘛

select id, name,gongzi=sum(gongzi)
from tbname
group by id


select [name],[gongzi]=sum(gongzi) from tb group by [name]

gongzi列应为int型

SQL code:

select [id], [name],sum(gongzi) as NewGongzi from yourtablename group by [name]



人家不要王五的

看错


SQL code


相关问答:

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 - 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 搜索语句 - .NET技术 / ASP.NET

<table style="width: 1000px"><tr>
  <td style="height: 38px; width: 35px;">
  姓名</td>
  ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号