sql server - Change Column1 to headers -


i getting amount of males/females have data on in our database. displaying as:

gender |  total ------------------ male   :  24251561 female :  24886049 

i need display as

male   | female ------------------ 24251561 : 24886049 

here current code data

select a.gender,count(1) (     select case when convert(int,substring(h.id_number,7,4)) < 5000     'female' else 'male' end gender cb_header h (nolock) h.id_number not null , dbo.vf_valid_id(h.id_number) = 1 )a group a.gender 

create table #pivot  (  gender varchar(100), total int ) insert #pivot values  ('male',24251561), ('female',24886049)    select *  (   select gender, total   #pivot ) src pivot (   max(total)   gender in ([male], [female]) ) piv;  male        female 24251561    24886049 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -