**#分组函数#1.查询公司员工工资的最大值,最小值,平均值,总和SELECTSUM(salary),MAX(salary),MIN(salary),AVG(salary),COUNT(salary)FROMemployees#工资去重**SELECTsum(DISTINCTsalary),sum(salary)FROMemployees#查询有几种工资SELECTcount(DISTINCTsa
**#流程控制函数#if函数**SELECTlast_name,commission_pct,IF(commission_pctISNULL,'没奖金,呵呵','有奖金,嘻嘻')FROMemployees**#case函数#查询员工工资,要求如果部门号=30,工资为1.1倍,如果部门号=40,工资为1.2倍,其他部门号工资为原工资**SELECTsalaryAS'原工资',department_i
**#一.字符函数#计算字符长度SELECTLENGTH('john')#显示编码格式SHOWVARIABLESLIKE'%char%'#转大小写**SELECTUPPER('john')SELECTLOWER('JOHN')SELECTSUBSTR('李莫愁爱上了陆展元',7)ASout_put#截取字符串SELECTSUBSTR('李莫愁
一.基础查询语句SELECT * FROM employees #查询员工号为176的员工姓名和部门号和年薪SELECT last_name AS 姓名, department_id AS 部门, salary*12*(1+IFNULL(commission_pct,0)) AS 年薪 FROM employees WHERE employee_id = 176 select last_na
Copyright © 2005-2024 51CTO.COM 版权所有 京ICP证060544号