sql学习6
时间:2010-09-25 来源:为你抒写
use zhongfei
select * from t_employee select fsubcompany,fdepartment from t_employee group by fsubcompany,fdepartment select fage,count(*) count from t_employee group by fage select fsubcompany,fage,count(*) count from t_employee group by fsubcompany,fage select fsubcompany,sum(fsalary) salary from t_employee group by fsubcompany select fdepartment,sum(fsalary) salary from t_employee group by fdepartment select fage,count(*) count from t_employee group by fage having count(*)>1 select fage,count(*) count from t_employee group by fage having count(*)>1 or count(*)<3 select fage,count(*) count from t_employee group by fage having count(*) in (1,3) select row_number() over (order by fsalary),fnumber,fname,fsalary,fage from t_employee select * from ( select row_number() over(order by fsalary desc) as rownum,fnumber,fname,fsalary,fage from t_employee ) as a where a.rownum between 3 and 5 where a.rownum>=3 and a.rownum<=5 select * from t_employee order by fsalary desc select top 3 * from t_employee order by fsalary desc select distinct fdepartment from t_employee select 'nanwang',3222,fname,fage,fsubcompany from t_employee select fnumber,fname,fage * fsalary from t_employee select * from t_employee where fsalary/(fage-15)>500 select '工号为'+fnumber +'的员工姓名为'+fname from t_employee where fname is not null update t_employee set fage=fage+1 相关阅读 更多 +