入门级的统计函数:
(1)统计记录数 count函数
可以统计出这条sql会查询出多少条记录很多人用count(*),但建议用count(1)
(2)求和函数 sum
select SUM(num) from tmp_p
对表中 num列进行求和
(3)求平均值
select AVG(num) from tmp_p
对表中 sum列进行求平均值.
(4)取出最大值
select MAX(num) from tmp_P
取出,num列中最大的一个
(5)取出最小值
select MIN(num) from tmp_P
取出,num列中最小的一个
(6)将数值型数据转换成字符型
select CONVERT(varchar(10),num) from tmp_p
该函数属于sql server的函数,其它数据库可参考相关资料