w3resource_MySQL练习:Basic_select_statement
w3resource_MySQL练习题:Basic_select_statement
- -- 要点:as设置别名,as可省略
- select first_name as "First Name", last_name as "Last Name"
- from employees
- -- 要点:select时添加distinct获取唯一值
- select distinct department_id
- from employees
- -- 要点:order by进行排序,desc进行降序排序
- select *
- from employees
- order by first_name desc
- -- 要点:select中可以进行数学运算
- select first_name, last_name, salary, salary*0.15 as PF
- from employees
- -- 要点:order by + asc
- select employee_id, first_name, last_name, salary
- from employees
- order by salary asc
- -- 要点:sum()加总
- select sum(salary)
- from employees
- -- 要点:max() + min()
- select max(salary), min(salary)
- from employees
- -- 要点:avg()均值 + count()计数
- select avg(salary), count(*)
- from employees
- -- 要点:count()
- select count(*)
- from employees
- -- 要点:count() + distinct
- select count(distinct job_id)
- from employees
- -- 要点:upper()
- select upper(first_name)
- from employees
- -- 要点:left()从左开始取字符
- select left(first_name, 3)
- from employees
- -- 要点:select可直接计算
- select 171*214+625
- -- 要点:concat()两列字符串组合
- select concat(first_name, ' ', last_name)
- from employees
- -- 要点:trim()去除两边空格
- select trim(first_name)
- from employees
- -- 要点:length()计算长度
- select length(first_name)+first_name(last_name)
- from employees
- -- 要点:where里使用 REGEXP 实现正则效果
- select *
- from employees
- where first_name REGEXP '[0-9]'
- -- 要点:limit限制取数量
- select *
- from employees
- limit 10
- -- 要点:round()实现小数位控制
- select first_name, last_name, round(salary/12, 2) as 'Monthly Salary'
- from employees
w3resource_MySQL练习:Basic_select_statement的更多相关文章
- w3resource_MySQL练习:Joins
w3resource_MySQL练习题:Joins 1. Write a query to find the addresses (location_id, street_address, city, ...
- w3resource_MySQL练习:Subquery
w3resource_MySQL练习题:Subquery 1. Write a query to find the name (first_name, last_name) and the salar ...
- w3resource_MySQL练习: Aggregate_functions
w3resource_MySQL练习题:Aggregate_functions 1. Write a query to list the number of jobs available in t ...
随机推荐
- RabbitMQ使用教程(一)RabbitMQ环境安装配置及Hello World示例
你是否听说过或者使用过队列? 你是否听说过或者使用过消息队列? 你是否听说过或者使用过RabbitMQ? 提到这几个词,用过的人,也许觉得很简单,没用过的人,也许觉得很复杂,至少在我没使用消息队列之前 ...
- 物体检测丨从R-CNN到Mask R-CNN
这篇blog是我刚入目标检测方向,导师发给我的文献导读,深入浅出总结了object detection two-stage流派Faster R-CNN的发展史,读起来非常有趣.我一直想翻译这篇博客,在 ...
- sqlserver 数据库 的数据库个数统计 表个数统计 表的数据量统计(转载)
http://www.cnblogs.com/qinche/archive/2012/08/09/app.html 由于今天要监控数据,急需统计实例中1有多少库2库里有多少表3每个表有多少数据 --将 ...
- 巧用伪元素绘制带边的三角形--CSS3
<!doctype html> <html lang="en"> <head> <meta charset="utf-8&quo ...
- 20170405JDBC数据查询
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"% ...
- JavaBean+jsp开发模式 --结合form表单 实例
1.创建form表单 <%@ page language="java" contentType="text/html; charset=UTF-8" pa ...
- 变更gcc版本
当前的GCC版本为GCC-4.2,需要切换到GCC-3.4.首先,你需要去你的usr/bin/下去看看有没有gcc-3.4这样文件,如果没有的话,就安装一下吧: apt-get install gcc ...
- CMSG_COMPAT_ALIGN函数
CMSG_COMPAT_ALIGN函数是什么的使用方法?
- (五)我的JavaScript系列:JavaScript的糟粕
泪眼问花花不语,乱红飞过秋千去. JavaScript的糟粕 JavaScript语言是一门集精华与糟粕于一体的语言.在JavaScript: the good parts中,便集中讨论了关于精华与糟 ...
- WisdomTool REST Client 下载 测试请求,生成api文档
https://github.com/Wisdom-Projects/rest-client