wasn t it:SQL语句怎么写?
来源:百度文库 编辑:中科新闻网 时间:2024/05/09 16:58:53
取前5个记录,并且算出字段aaa的平均值,表中记录总数
要求还要取出其他的字段的值!!
alby提供的不能取出其他字段/。比如字段YourName
要求还要取出其他的字段的值!!
alby提供的不能取出其他字段/。比如字段YourName
select avg(aaa) as f1,count(1) as f2 from thetable where id in (select top 5 id from thetable)
id:索引
thetable:表名
select avg(aaa) from table_name where id<5;
select count(*) from table_name;
select top 5*
from '你要查寻的表
计算平均值的公式在select后面加,这个公式我不太清楚
select top 5 ,avg(aaa), count(*)from x