select '49年以前' 领取年份,
count(*) * 100 / (select count(*) from yourtable) 百分比
from yourtable where edate < '1949-1-1'
union all
select 49年到90年' 领取年份,
count(*) * 100 / (select count(*) from yourtable) 百分比
from yourtable where edate between '1949-1-1' and '1990-1-1'
union all
select '90年到现在' 领取年份,
count(*) * 100 / (select count(*) from yourtable) 百分比
from yourtable where edate >= '1990-1-1'
count(*) * 100 / (select count(*) from yourtable) 百分比
from yourtable where edate < '1949-1-1'
union all
select 49年到90年' 领取年份,
count(*) * 100 / (select count(*) from yourtable) 百分比
from yourtable where edate between '1949-1-1' and '1990-1-1'
union all
select '90年到现在' 领取年份,
count(*) * 100 / (select count(*) from yourtable) 百分比
from yourtable where edate >= '1990-1-1'
select sum((case when 工资的领取年份 <= 1949 then 1 else 0 end))
as 领取年份49年以前,
sum((case when 工资的领取年份 between 1949 + 1 and 1990 - 1 else 0 end))
as 领取年份1950-1989年,
sum((case when 工资的领取年份 >= 1990 else 0 end))
as 领取年份1990年以后
from tablename
select round(sum((case when 工资的领取年份 <= 1949 then 1 else 0 end))
/ (select count(*) from tablename),2)
as 领取年份49年以前,
round(sum((case when 工资的领取年份 between 1949 + 1 and 1990 - 1 else 0 end))
/ (select count(*) from tablename),2)
as 领取年份1950-1989年,
round(sum((case when 工资的领取年份 >= 1990 else 0 end))
/ (select count(*) from tablename),2)
as 领取年份1990年以后
from tablename
cast((count(*) * 100 / (select count(*) from yourtable)) as varchar(10)) + '%' as 百分比
from yourtable where edate < '1949-1-1'
union all
select 49年到90年' ,
cast((count(*) * 100 / (select count(*) from yourtable)) as varchar(10)) + '%'
from yourtable where edate between '1949-1-1' and '1990-1-1'
union all
select '90年到现在' ,
cast((count(*) * 100 / (select count(*) from yourtable)) as varchar(10)) +'%'
from yourtable where edate >= '1990-1-1'
when year(年份) between 1949 and 1990
when year(年份) between 1990 and year(getdate())
when year(年份) between 1949 and 1990 then 'b'
when year(年份) between 1990 and year(getdate()) then 'c'