你的位置:首页 > 软件开发 > ASP.net > SQL Server 中位数、标准差、平均数

SQL Server 中位数、标准差、平均数

发布时间:2015-10-12 16:00:12
create table examines( [e_id] [int] IDENTITY(1,1) NOT NULL, [dept_name] [nvarchar](200) NULL, [ph_score] [int] NULL)SELECT dept_name, A ...
create table examines(  [e_id] [int] IDENTITY(1,1) NOT NULL,  [dept_name] [nvarchar](200) NULL,  [ph_score] [int] NULL)SELECT  dept_name,  AVG(sp) as '中位數'FROM(  SELECT   dept_name,   cast(ph_score as decimal(5,2)) sp,   ROW_NUMBER() OVER (     PARTITION BY dept_name     ORDER BY ph_score ASC, e_id ASC) AS RowAsc,   ROW_NUMBER() OVER (     PARTITION BY dept_name     ORDER BY ph_score DESC, e_id DESC) AS RowDesc  FROM examines SOH) xWHERE  RowAsc IN (RowDesc, RowDesc - 1, RowDesc + 1)GROUP BY dept_nameORDER BY dept_name;select dept_name,STDEV(ph_score) as '標準差' from examines group by dept_nameselect dept_name,avg(ph_score) as '平均數' from examines group by dept_name

 

海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com

原标题:SQL Server 中位数、标准差、平均数

关键词:sql

sql
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。