SQL中的函数
来源:互联网 发布:手机添加网络什么意思 编辑:程序博客网 时间:2024/06/07 10:13
查询语句集合(函数)
1.count
select count(customer) as count from `order` where customer = 'Bush';
select count(*) as numberOfOrders from `order` ;
select count(distinct customer) as typeOfOrders from `order` ;
2.first
select first(oprice) as maxPrice from `order`;
3.last
select last(oprice) as maxPrice from `order`;
4.max
select max(oprice) as maxPrice from `order`;
5.min
select min(oprice) as minPrice from `order`;
6.sum
select sum(oprice) as totalPrice from `order`;
7.GROUP BY
select customer , SUM(oprice) from `order` group by customer ;
select customer , odate , SUM(oprice) from `order` group by customer , odate;
8.HAVING 在group by 中添加的条件
select customer , SUM(oprice) from `order` group by customer having SUM(oprice) > 0 ;
9.切换成大写ucase(字段名)
select ucase(lastName) from person;
select ucase(lastName) as Lastname , firstName from person;
10.切换成小写 lcase(字段名)
select lcase(lastName) as Lastname , firstName from person;
11.查询某个字段的部分字符 mid(字段名,开始下标,长度)
select mid(city,1,3) from person;
12.查询某个字段的长度 length(字段名)
select length(city) as cityLength from person;
1.count
select count(customer) as count from `order` where customer = 'Bush';
select count(*) as numberOfOrders from `order` ;
select count(distinct customer) as typeOfOrders from `order` ;
2.first
select first(oprice) as maxPrice from `order`;
3.last
select last(oprice) as maxPrice from `order`;
4.max
select max(oprice) as maxPrice from `order`;
5.min
select min(oprice) as minPrice from `order`;
6.sum
select sum(oprice) as totalPrice from `order`;
7.GROUP BY
select customer , SUM(oprice) from `order` group by customer ;
select customer , odate , SUM(oprice) from `order` group by customer , odate;
8.HAVING 在group by 中添加的条件
select customer , SUM(oprice) from `order` group by customer having SUM(oprice) > 0 ;
9.切换成大写ucase(字段名)
select ucase(lastName) from person;
select ucase(lastName) as Lastname , firstName from person;
10.切换成小写 lcase(字段名)
select lcase(lastName) as Lastname , firstName from person;
11.查询某个字段的部分字符 mid(字段名,开始下标,长度)
select mid(city,1,3) from person;
12.查询某个字段的长度 length(字段名)
select length(city) as cityLength from person;
0 0
- SQL中的单行函数
- sql中的case函数
- Sql中的getDate()函数
- SQL中的Stuff()函数
- SQL中的replace函数
- sql 中的Replace函数
- SQL中的Stuff()函数
- SQL中的replace函数
- 编写sql中的函数
- SQL 中的Stuff函数
- sql中的常见函数
- sql中的datediff()函数
- SQL中的常用函数
- SQL中的时间函数
- SQL中的replace函数
- SQL中的内置函数
- sql中的函数
- sql中的convert函数
- 容易被忽略的xcode xcworkspace
- res\mipmap-xxxhdpi-v4\ic_launcher.png:0:Originally defined here
- iOS7,iOS8,iOS9适配
- sqlite3使用简介
- Found 4 versions of android-support-v4.jar in the dependency list 解决方案
- SQL中的函数
- UITableView使用详解 相当详细
- Junit4 单元测试
- 一个SingleTask与跳转传值引发的血案
- c++ 11 多线线程系列-----------原子操作(atomic operation)
- 【Android开发—电商系列】(一):ListView,就这么美
- ubuntu14.04,安装docker(源代码管理工具)
- UE4学习笔记23th
- guava文件操作