SQL的聚合函数与排序
技术百科
php中世界最好的语言
发布时间:2018-03-26
浏览: 次 这次给大家带来SQL的聚合函数与排序,使用SQL聚合函数与排序的注意事项有哪些,下面就是实战案例,一起来看一下。
count 函数
语法:
Select count(*)|count(列名) from table_name [where where_defination];Select count(id) from stu;Select count(name) from stu where math > 90;select count (name) from stu where chines+math+English> 250;
sum函数
Select sum (列名) from stu [where where_defination]; Select sum (列名),sum(列名), sum(列名) from stu [where where_definition]; Select sum (列名)+sum(列名)+ sum(列名) from stu [where where_definition]; Select sum (列名)+sum(列名)+sum(列名) as 总分 from stu [where where_definition]; Select sum (列名)/count(name) from stu [where where_defination]; Select avg(math) from stu; Select avg(math + chines + english) from stu; Select max|min(列名) from stu; Select max(math + chines + english) from stu; Select min(math + chines + english) from stu;
对查询结果排序
使用order by 子句排序查询结果
Select column1, column2, column3 from table order by column asc|desc
order by指排序的列,也可以是select后面指定的列名
order by 子句应位于select 语句的结尾
Select name, math from stu order by math; select name, math+english+chines from stu order by math+english+chines desc; select name, math+english+chines from stu where name like 'zhang%' order by math+english+chines desc;
相信看了本文案例你已经掌握了方法,更多精彩请关注其它相关文章!
推荐阅读:
分页查询的使用详解
JS的日期相关函数使用详解
# 看了
# 分页
# 相关文章
# 有哪些
# 给大家
# 你已经
# JS
# select
# php
# sql
# count
# 更多精彩
# 子句
# 查询结果
# math
相关栏目:
<?muma
$count = M('archives')->where(['typeid'=>$field['id']])->count();
?>
【
AI推广<?muma echo $count; ?>
】
<?muma
$count = M('archives')->where(['typeid'=>$field['id']])->count();
?>
【
SEO优化<?muma echo $count; ?>
】
<?muma
$count = M('archives')->where(['typeid'=>$field['id']])->count();
?>
【
技术百科<?muma echo $count; ?>
】
<?muma
$count = M('archives')->where(['typeid'=>$field['id']])->count();
?>
【
谷歌推广<?muma echo $count; ?>
】
<?muma
$count = M('archives')->where(['typeid'=>$field['id']])->count();
?>
【
百度推广<?muma echo $count; ?>
】
<?muma
$count = M('archives')->where(['typeid'=>$field['id']])->count();
?>
【
网络营销<?muma echo $count; ?>
】
<?muma
$count = M('archives')->where(['typeid'=>$field['id']])->count();
?>
【
案例网站<?muma echo $count; ?>
】
<?muma
$count = M('archives')->where(['typeid'=>$field['id']])->count();
?>
【
精选文章<?muma echo $count; ?>
】
相关推荐
- Windows 11无法安全删除U盘提示设备正在使
- Go 语言标准库为何不提供泛型 Contains
- Windows10无法连接到Internet_Wi
- Win11怎么关闭用户账户控制UAC_Window
- 如何使用Golang实现聊天室消息存档_存储聊天记
- C++ static_cast和dynamic_c
- Win10怎样安装Excel数据分析工具_Win1
- Python 中将 ISO 8601 时间戳转换为
- Python文件管理规范_工程实践说明【指导】
- Windows10怎么备份注册表_Windows1
- php删除数据怎么软删除_添加is_del字段标记
- PythonFastAPI项目实战教程_API接口
- PHP主流架构怎么集成Redis缓存_配置步骤【方
- c++ std::future和std::prom
- Win11怎么清理C盘系统日志_Win11清理系统
- Python大文件处理策略_内存优化说明【指导】
- Windows10如何更改鼠标灵敏度_Win10鼠
- Win11摄像头无法使用怎么办_Win11相机隐私
- php中常量能用::访问吗_类常量与作用域操作符使
- PHP怎么接收URL中的锚点参数_获取#后面参数值
- GML (Geography Markup Lan
- Win11怎么关闭通知消息_屏蔽Windows 1
- php怎么下载安装后设置错误日志_phpini l
- Mac如何与安卓手机传文件_Mac和Android
- Win10闹钟铃声怎么自定义 Win10闹钟自定义
- 如何使用Golang实现跨域请求支持_Golang
- Win10怎样卸载DockerDesktop_Wi
- Ajax提交表单PHP怎么接收_处理Ajax发送的
- MySQL 中使用 IF 和 CASE 实现查询字
- php能控制zigbee模块吗_php通过串口与c
- Win11关机快捷键是什么_Win11快速关机方法
- Win11怎么关闭防火墙通知_屏蔽Win11安全中
- 如何使用Golang安装依赖库_管理模块和第三方包
- Dapper的Execute方法的返回值是什么意思
- php8.4匿名类怎么用_php8.4匿名类创建与
- Win10怎么设置开机密码_Windows10账户
- Windows10电脑怎么查看硬盘通电时间_Win
- 如何使用Golang实现基本类型比较_Golang
- Windows怎样拦截WPS弹窗广告_Window
- php订单日志怎么按金额排序_php按订单金额排序
- Python 模块的 __name__ 属性如何由
- Golang如何测试HTTP中间件_Golang
- PHP怎么接收前端传的时间戳_处理时间戳参数转换技
- Windows10无法识别USB设备描述符请求失败
- 如何使用Golang实现微服务事件驱动_使用消息总
- Win11怎么开启窗口对齐助手_Windows11
- c# 在高并发场景下,委托和接口调用的性能对比
- 如何使用 Python 合并文件夹内多个 Exce
- Win11文件扩展名怎么显示_Win11查看文件后
- Win11触摸板没反应怎么办_开启Win11笔记本

+english+chines from stu where name like 'zhang%' order by math+english+chines desc;
QQ客服