sql语言诞生有一段时间了,里面有一些自带的很方便的函数,对于操作数据库来说是非常方便的,下面就介绍几种统计 方法/步骤 统计记录数 count函数 可以统计出这条sql会查询出多少条记录很多人用count(*),但建议用count(1) 求合函数 sum select SUM(num) from tmp_p 对表中 num列进行求合. 求平均值 select AVG(num) from tmp_p 对表中 sum列进行求平均值. 取出最大值 select MAX(num) from tmp_P 取出,num列中最大的一个 取出最小值 select MIN(num) from tmp_P 取出,num列中最小的一个 将数值型数据转换成字符型 select CONVERT(varchar(10),num) from tmp_p 该函数属于sql server的函数,其它数据库可参考相关资料
|
