去掉數據重復
增加兩個字段
alter TABLE T_Employee Add FSubCompany VARchar(20);
ALTER TABLE T_Employee ADD FDepartment VARCHAR(20);
給新加的字段賦值
UPDATE T_Employee SET FSubCompany='Beijing',FDepartment='Development' where FNumber='DEV001';
UPDATE T_Employee SET FSubCompany='ShenZhen',FDepartment='Development' where FNumber='DEV002';
UPDATE T_Employee SET FSubCompany='Beijing',FDepartment='HumanResource' where FNumber='HR001';
UPDATE T_Employee SET FSubCompany='Beijing',FDepartment='HumanResource' where FNumber='HR002';
UPDATE T_Employee SET FSubCompany='Beijing',FDepartment='InfoTech' where FNumber='IT001';
UPDATE T_Employee SET FSubCompany='ShenZhen',FDepartment='InfoTech' where FNumber='IT002';
UPDATE T_Employee SET FSubCompany='Beijing',FDepartment='Sales' where FNumber='SALES001';
UPDATE T_Employee SET FSubCompany='Beijing',FDepartment='Sales' where FNumber='SALES002';
UPDATE T_Employee SET FSubCompany='ShenZhen',FDepartment='Sales' where FNumber='SALES003';
查詢並去重
select distinct FDepartment from T_Employee
select distinct FDepartment,FSubCompany from T_Employee