sql 查询一行内几列的平均值,最大值,最小值,怎么写
sql 查询一行内几列的平均值,最大值,最小值,怎么写
日期:2012-03-21 19:22:57 人气:2
oracle的话直接用greatest函数,sql server的话照这么写:
select t1.name, max(t1.a) maxnum,min(t1.a) minnum,avg(t1.a) avgnum from
(select name,num1 a from tb1
union all
select name,num2 a from tb1
union all
select name,num3 a from tb1
union all
select name,num