关于TP的sum方法,能一次sumoracle sum 多个字段段返回么

thinkphp sum统计多个字段的和 - ThinkPHP框架
thinkphp sum可以统计多个字段的和吗??求助
ThinkPHP 是一个免费开源的,快速、简单的面向对象的 轻量级PHP开发框架 ,创立于2006年初,遵循Apache2开源协议发布,是为了敏捷WEB应用开发和简化企业应用开发而诞生的。ThinkPHP从诞生以来一直秉承简洁实用的设计原则,在保持出色的性能和至简的代码的同时,也注重易用性。并且拥有众多的原创功能和特性,在社区团队的积极参与下,在易用性、扩展性和性能方面不断优化和改进,已经成长为国内最领先和最具影响力的WEB应用开发框架,众多的典型案例确保可以稳定用于商业以及门户级的开发。Unexpected character in input:
' in D:\php186\\index.php on line 38
&& && &&&& && &&其它登录: &&
您的位置:>
& thinkphp 3.2 sql语句统计查询Count|Max|Min|Avg|Sum函数用法
thinkphp 3.2 sql语句统计查询Count|Max|Min|Avg|Sum函数用法
时间: 17:52:48 & 编辑:一切随缘 & 文章来源:php教程网 已阅读:12528 次
广告投放:
WEB开发网:
&&& &&& thinkphp 3.2
sql语句统计查询Count|Max|Min|Avg|Sum函数用法
在应用中我们经常会用到一些统计数据,例如当前所有(或者满足某些条件)的用户数、所有用户的最大积分、用户的平均成绩等等,ThinkPHP为这些统计操作提供了一系列的内置方法,包括:
&&& 方法 &&& 说明
&&& &&& Count &&& 统计数量,参数是要统计的字段名(可选)
&&& &&& Max &&&
获取最大值,参数是要统计的字段名(必须)
&&& &&& Min &&& 获取最小值,参数是要统计的字段名(必须)
&&& &&& Avg &&&
获取平均值,参数是要统计的字段名(必须)
&&& &&& Sum &&& 获取总分,参数是要统计的字段名(必须)
&&& &&& 用法示例:
&&& &&& &&& $User =
M(&User&); // 实例化User对象
&&& &&& 获取用户数:
&&& &&& &&& $userCount =
$User-&count();
&&& &&& 或者根据字段统计:
&&& &&& &&& $userCount =
$User-&count(&id&);
&&& &&& 获取用户的最大积分:
&&& &&& &&& $maxScore =
$User-&max('score');
&&& &&& 获取积分大于0的用户的最小积分:
&&& &&& &&&
$minScore = $User-&where('score&0')-&min('score');
获取用户的平均积分:
&&& &&& &&& $avgScore = $User-&avg('score');
&&& &&& 统计用户的总成绩:
&&& &&& &&&
$sumScore = $User-&sum('score');
并且所有的统计查询均支持连贯操作的使用。
上一篇:|>=|<|thinkphp[=||>|>=|<|<=|BETWEEN|LIKE|EXP|IN]条件查询语句代码下一篇:
本文地址:/content/article/php-xuexi/22503.html(转载请保留)
相关关键词搜索:thinkphp,3.2,sql,计查询,Count,Max,Min,Avg,Sum
你可能喜欢
php sprintf与printf函数用法区别,下面是一个示例:四舍五入保留小数点后两位...
php ereg_replace将其替换replacement@替换的匹配项则会返回原字符串,string ereg_replace ( string $pattern , str...
php计算e的指数@php exp用法示例, float exp ( float $arg ), 返回 e 的 arg 次方值。
Note: 用 \'e\' 作为自然对数的底 2...
php判断文件或目录是否存在@php file_exists函数教程, bool file_exists ( string $filename ),如果由 filename 指定的...
* 以上用户言论只代表其个人观点,不代表网站的观点或立场
纯JS代码小游戏
热门关键词
(已有956人阅读本文)
(已有1035人阅读本文)
(已有764人阅读本文)
(已有1907人阅读本文)
(已有1753人阅读本文)
(已有796人阅读本文)
(已有2478人阅读本文)
(已有1127人阅读本文)
(已有1629人阅读本文)
WEB技术QQ交流群: 站长Q号:
版权所有者:WEB开发网 地址:云南省文山州砚山县盘龙乡
滇ICP备号-1
特别声明:本站内容仅供参考,不作为设计及确切依据!想了解更多,可立即进入_____summous的喜欢 | LOFTER(乐乎) - 让兴趣,更有趣
LOFTER for ipad —— 让兴趣,更有趣
_____summous 的喜欢
&nbsp&nbsp被喜欢
&nbsp&nbsp被喜欢
{list posts as post}
{if post.type==1 || post.type == 5}
{if !!post.title}${post.title|escape}{/if}
{if !!post.digest}${post.digest}{/if}
{if post.type==2}
{if post.type == 3}
{if !!post.image}
{if post.type == 4}
{if !!post.image}
{if !!photo.labels && photo.labels.length>0}
{var wrapwidth = photo.ow < 500?photo.ow:500}
{list photo.labels as labs}
{var lbtxtwidth = Math.floor(wrapwidth*(labs.ort==1?labs.x:(100-labs.x))/100)-62}
{if lbtxtwidth>12}
{if !!labs.icon}
{list photos as photo}
{if photo_index==0}{break}{/if}
品牌${make||'-'}
型号${model||'-'}
焦距${focalLength||'-'}
光圈${apertureValue||'-'}
快门速度${exposureTime||'-'}
ISO${isoSpeedRatings||'-'}
曝光补偿${exposureBiasValue||'-'}
镜头${lens||'-'}
{if data.msgRank == 1}{/if}
{if data.askSetting == 1}{/if}
{if defined('posts')&&posts.length>0}
{list posts as post}
{if post_index < 3}
{if post.type == 1 || post.type == 5}
{if !!post.title}${post.title|escape}{/if}
{if !!post.digest}${post.digest}{/if}
{if post.type == 2}
{if post.type == 3}
{if post.type == 4}
{if post.type == 6}
{if drlist.length>0}
更多相似达人:
{list drlist as dr}{if drlist.length === 3 && dr_index === 0}、{/if}{if drlist.length === 3 && dr_index === 1}、{/if}{if drlist.length === 2 && dr_index === 0}、{/if}{/list}
暂无相似达人,
{if defined('posts')&&posts.length>0}
{list posts as post}
{if post.type == 2}
{if post.type == 3}
{if post.type == 4}
{if post.type == 6}
this.p={ dwrMethod:'queryLikePosts',fpost:'1cb974cd_6192ed3',userId:,blogListLength:10};

我要回帖

更多关于 select sum 字段求和 的文章

 

随机推荐