SQL 求平均数问题
我想把表A变成表B,就是把字段3 根据字段1求平均数 怎么写SQL语句啊
求高手帮忙
-------------------------------
表A
字段1 字段2 字段3
A A1 150
A A2 150
A A3 150
B B1 120
B B2 120
----------------------------------
表B
字段1 字段2 字段3
A A1 50
A A2 50
A A3 50
B B1 60
B B2 60
--------------------------------------------------
SQL code:
SELECT
字段1 ,
字段2 ,
(SELECT AVG(字段3) from TB WHERE 字段1=T.字段1)字段3
from TB T
SQL code:
/*
*************************************
* T-MAC 小编 *
* -->努力成长中 *
* -->梦想DBA *
*************************************
*/
if OBJECT_ID('表A') is not null
drop table 表A
go
create table
相关问答:
执行的顺序:
1)文件浏览框(选择文件使用)
选择好文件后
点击一个导入按钮的时候 ,把上面上传框里的csv文件以一个ID为文件名,上传到**/**文件夹下
2)读取这个文件夹下的csv的文件,转换成sql
3 ......
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
字段1,字段2.....字段N,Status,ParentID
1,Name1....test1,1,99
1,Name1....test1,3,99
1,Name2....test2,1,101
1,Name2....test2,3,101
1,Name3....test3,2,101
1,Name1....test1,4,101
想要的结果是:
1,Na ......
第一句:
select ht.gfdm,gfdm.gfmc,gfdm.lb ,sum(jh.htdj*jh.htsl)as je
from ht left join gfdm on ht.gfdm=gfdm.gfdm
join jh on ht.htbh=jh.hth
and ht.htbh not like'del%' and ht. ......