#建立一個資料庫
create database why;
#建立一個使用者表
create table why(employee_id bigint,name char(16),gerder enum('M','F'),dept_id enum('caiwu','renshi','shichang','jishu'),join_time date,salary double,phone char(11),address char(40),description text);
#建立使用者記錄
insert into why values(20121200*(#序號),'name','F/M','caiwu/renshi/shichang/jishu','2012-10-07,*(#工資),'*'(#電話),'address','description')
#實現sql查詢
按名字尋找
select * from why where name='name'; #尋找某個人的個人資訊
按照薪水>尋找
select * from why where salary>=3000 and salary<=10000;#尋找薪水高於3000(含3000) 低於1w(含10000)的所有人
尋找每個部門的人數
select dent_id,count(*) as dentsum from why group by dept_id;
每個部門的平均薪資
select dent_id,avg(salary) as avgsalary from why group by dept_id;
描述欄位為空白的員工
select * from why where description is null; #所有資訊均為空白(包括使用者姓名)
select * from why where description='';#只有描述資訊為空白
求出每個部門女員工工資最高的職工的薪水
select dept_id max(salary) from why where gerder='F' group by dept_id;
名字以l開頭的員工個數
select * from why where name like "l%"