去掉数据重复 增加两个字段 alter TABLE T_Employee Add FSubCompany VARchar(); ALTER TABLE T_Employee ADD FDepartment VARCHAR(); 给新加的字段赋值 UPDATE T_Employee SET FSubCompany='Beijing',FDepartment='Development' where FNumber='DEV'; UPDATE T_Employee SET FSubCompany='ShenZhen',FDepartment='Development' where FNumber='DEV'; UPDATE T_Employee SET FSubCompany='Beijing',FDepartment='HumanResource' where FNumber='HR'; UPDATE T_Employee SET FSubCompany='Beijing',FDepartment='HumanResource' where FNumber='HR'; UPDATE T_Employee SET FSubCompany='Beijing',FDepartment='InfoTech' where FNumber='IT'; UPDATE T_Employee SET FSubCompany='ShenZhen',FDepartment='InfoTech' where FNumber='IT'; UPDATE T_Employee SET FSubCompany='Beijing',FDepartment='Sales' where FNumber='SALES'; UPDATE T_Employee SET FSubCompany='Beijing',FDepartment='Sales' where FNumber='SALES'; UPDATE T_Employee SET FSubCompany='ShenZhen',FDepartment='Sales' where FNumber='SALES'; 查询并去重 select distinct FDepartment from T_Employee select distinct FDepartment,FSubCompany from T_Employee
推荐整理分享SQL学习笔记五去重,给新加字段赋值的方法(sql基本教程),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:sql必学必会,sql 5,sql必知必会第五版,sql5.7,sql 5,sql 5,sql语句笔记,sql必知必会第五版,内容如对您有帮助,希望把文章链接给更多的朋友!
SQL学习笔记六 union联合结果集使用 联合结果集新建临时工数据表CREATETABLET_TempEmployee(FIdCardNumberVARCHAR(),FNameVARCHAR(),FAgeint,PRIMARYKEY(FIdCardNumber));INSERTINTOT_TempEmployee(FIdCardNumber,FName,FAge)VALUES('
SQL学习笔记七函数 数字,日期,类型转换,空值处理,case 数字函数ABS():求绝对值。CEILING():舍入到最大整数。FLOOR():舍入到最小整数。ROUND():四舍五入ROUND(A,B)A是要处理的数,B是精确到小数点后第几位LEN():计算
SQL学习笔记八 索引,表连接,子查询,ROW_NUMBER 索引经常要查询的语句,则给它建一个索引表连接selectT_OdersasojoinT_CustomersasCono.CustomerId=c.Id子查询单值子查询单列多值子查询ROW_NUMBER()函数ROW_NUMBER()OVER(O