日期:2014-05-17 浏览次数:20414 次
--usserinf
if object_id('usserinf','u') is not null
drop table usserinf
go
create table usserinf
(
userid char(4),
user_Identity smallint,
user_MemberOrParty smallint,
user_Organize smallint
)
go
insert into usserinf values
('1000',0,1,1),
('1001',1,2,0),
('1002',2,1,2),
('1003',1,0,0),
('1004',1,1,2),
('1005',2,2,1)
go
--SQL
--结果一
select *from (
select '默认' 中文, count(默认) Tag from(
select
case when user_Identity=0 then user_Identity else null end 默认
from usserinf) A
where 默认 is not null union all
select '一般', count(一般) Tag from(
select
case when user_Identity=1 then user_Identity else null end 一般
from usserinf) A
where 一般 is not null union all
select '普通', count(普通) Tag from(
selec