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
速度都很快嘛
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
相关问答:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
--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 ......
<table style="width: 1000px"><tr>
<td style="height: 38px; width: 35px;">
姓名</td>
......