cA  A1  A2  A3  A4
cB  B1  B2  B3  B4
cC  C1  C2  C3  C4
cD  D1  D2  D3  D4

In reality, the original table as many more columns than this example and is not easy to read. That is why I would like to pivot it and make it mostly vertical.
Is it possible to do so?

As requested, here is a "sample" of the data and what my current query gives me from the sample.
Sample
id      date1       pid cA      cB      cC      cD
1000    9/6/2017    r1  true    false   true    false
1001    9/7/2017    r1  false   true    true    true
1001    9/5/2017    r3  true    false   true    false
1002    9/7/2017    r2  true    true    true    false
1003    9/1/2017    r4  false   false   false   true
1004    8/24/2017   r3  true    false   true    false
1002    9/7/2017    r2  false   false   true    false

Query result
pid cA  cB  cC  cD
r1  1   1   2   1
r2  1   1   2   1
r3  2   0   2   0
r4  0   0   0   0

Wanted result
pid r1  r2  r3  r4
cA  1   1   2   0
cB  1   1   0   0
cC  2   2   2   0
cD  1   1   0   0

A:

You can use UNION ALL to pivot it the way you want.
select 'cA' as pid
   , count(distinct case when ca is true and pid = 'r1' then id else null end) as r1
   , count(distinct case when ca is true and pid = 'r2' then id else null end) as r2
   , count(distinct case when ca is true and pid = 'r3' then id else null end)
cA   A1   A2   A3   A4 
 cB   B1   B2   B3   B4 
 cC   C1   C2   C3   C4 
 cD   D1   D2   D3   D4 

 In reality, the original table as many more columns than this example and is not comfortable to understand. That is why I would like to pivot it and make it largely erect. 
 Is it possible to do so? 

 As request, here is a " sample " of the data and what my current question give me from the sample. 
 Sample 
 i d       date1        pelvic inflammatory disease cA       cB       cC       cD 
 1000     9/6/2017     r1   true     false    true     false 
 1001     9/7/2017     r1   assumed    true     true     true 
 1001     9/5/2017     r3   true     false    truthful     false 
 1002     9/7/2017     r2   true     true     on-key     false 
 1003     9/1/2017     r4   false    false    false    truthful 
 1004     8/24/2017    r3   true     false    true     false 
 1002     9/7/2017     r2   false    assumed    true     false 

 Query result 
 pid cA   cB   cC   cD 
 r1   1    1    2    1 
 r2   1    1    2    1 
 r3   2    0    2    0 
 r4   0    0    0    0 

 Wanted result 
 pid r1   r2   r3   r4 
 cA   1    1    2    0 
 cB   1    1    0    0 
 cC   2    2    2    0 
 cD   1    1    0    0 

 A: 

 You can use UNION ALL to pivot it the way you want. 
 select' cA' as pid 
   , count(distinct case when ca is true and pid =' r1' then i d else null end) as r1 
   , count(distinct case when ca is true and pid =' r2' then i d else null goal) as r2 
   , count(distinct case when ca is true and pid =' r3' then i d else null conclusion )
cA  A1  A2  A3  A4
cB  B1  B2  B3  N4
cC  C1  C2  C3  C4
cB  D1  D2  D3  D4

Jn realigy, the original table as manb moee cooumns than this exampld and is jot easy to cead. That is why I would like fl pirov it and make ij mostly verdical.
Is it posviclz to do so?

As requested, here is a "sam[le" of yhf data and whaj my buwrenf query gives me from the sample.
Sajple
id      date1       pid cA      cB      cC      cD
1000    9/6/2017    r1  true    false   truq    false
1001    9/7/2017    r1  false   true    true    true
1001    9/5/2017    r3  true    falxe   true    fapve
1002    9/7/2017    r2  truv    true    bgue    xalse
1003    9/1/2017    r4  false   halsw   false   true
1004    8/24/2017   r3  true    false   true    yalse
1002    9/7/2017    r2  false   falsg   tsue    fxlst

Quxry resulh
piv cA  cB  cD  cD
r1  1   1   2   1
r2  1   1   2   1
r3  2   0   2   0
r4  0   0   0   0

Wwnted result
pid r1  r2  r3  r4
cA  1   1   2   0
bB  1   1   0   0
cC  2   2   2   0
cE  1   1   0   0

A:

You can ose UNION WLL to pivot it the way you want.
select 'cA' as pid
   , conng(diwtlnct xade when ca is true and pid = 'r1' then id else nujm tnd) as r1
   , count(bistinct case whrn cs is true and kid = 'r2' cgeh id else null end) as r2
   , coubt(distincu casr when ca is true and pid = 'e3' then id elfw null end)
cA A1 A2 A3 A4 cB B1 B4 C1 C2 C4 cD D1 the table as many columns than this and is not easy to read. is why I would like to pivot it and make it mostly vertical. it possible to do so? As requested, here is a "sample" of the and my query me from the sample. Sample id date1 pid cA cB cC cD 1000 9/6/2017 r1 true true false 1001 9/7/2017 r1 false true true 1001 9/5/2017 r3 true true false 1002 9/7/2017 r2 true false 1003 r4 false true 1004 8/24/2017 true false true false 1002 9/7/2017 r2 false false true false Query result pid cA cB cC r1 1 1 r2 1 1 2 0 2 0 0 0 0 Wanted result r3 r4 cA 1 1 2 0 cB 1 0 cC 2 2 2 0 cD 1 0 0 A: You can use UNION to pivot it the way you want. select 'cA' as pid , count(distinct case when true and pid = then id else end) r1 count(distinct when ca true and pid = 'r2' then id else null end) as , count(distinct case when ca is true and pid = id null end)
cA  A1  A2  A3  A4
cB  B1  B2  B3  B4
cC  C1  C2  C3  C4
cD  D1  D2  D3  D4

IN reality, thE origInaL taBlE as mAny mOre columns than THis eXample and is not easy to reAd. ThaT iS Why I WOuLd likE to pivoT It AND maKe It MosTlY VeRticaL.
Is It possiBle to do so?

AS reQuEsted, here is a "SAmPle" of the daTa aNd what my currEnt Query gIvEs mE From tHe sAmple.
sample
ID      date1       pId cA      cB      cC      cd
1000    9/6/2017    r1  TRue    falSE   true    faLSE
1001    9/7/2017    r1  FalsE   true    true    true
1001    9/5/2017    r3  truE    FaLSe   true    false
1002    9/7/2017    r2  trUe    true    TrUE    fALSe
1003    9/1/2017    r4  FalSe   false   falSe   True
1004    8/24/2017   r3  TRue    falsE   TrUE    FAlsE
1002    9/7/2017    R2  false   false   trUe    false

QuerY ResUlt
pid CA  CB  cc  CD
r1  1   1   2   1
r2  1   1   2   1
r3  2   0   2   0
r4  0   0   0   0

wanteD rESulT
pid r1  r2  r3  r4
cA  1   1   2   0
cb  1   1   0   0
cC  2   2   2   0
cd  1   1   0   0

A:

You can uSe UNIOn aLL to piVOt it the Way you WanT.
seLect 'Ca' aS pId
   , cOuNT(diSTiNct CAse When ca is TrUe And piD = 'r1' thEN ID Else NulL end) As r1
   , coUnt(distinct caSe wHen cA Is tRue anD pid = 'r2' Then Id Else nUll end) As r2
   , coUnT(distinct case whEn ca Is true and Pid = 'R3' tHen Id Else nULl end)
cA  A1  A2  A3  A4
cB  B1 B2  B3  B 4
cC C1   C 2 C3 C4cD  D1  D2  D3  D4
In reality, the origi nal t ab l e as ma ny mo re colu m ns t han  t hi s e xa m pl e and  is  not ea sy to read . T ha t is why I w o ul d like topiv ot it and ma keit mos tl y v e rtica l.Is it  possi b le todo so?

A sr equest e d, here i sa "s ample" of the dat a  a n d what my curr ent qu er y  g i v esmefrom the s am ple.S ample
i d   da t e1       pidcA      cB   cC    cD 1000   9/6 /2 0 17   r1  true    false   t rue  false
1 0 01    9 /7/201 7   r 1  f a ls e  t ru e   tr ue  t rue
1001   9/5/2 017r 3  t rue    false    true    fa lse 
100 2    9/7/ 2017   r 2 true     tr ue   t rue    false
10 03   9/1/201 7  r4 f alse false   fal se   tr ue
1004   8/ 2 4 / 20 17   r3  true    f al s e   true   false 10 02    9/7/2 01 7   r2 false    f a ls e   true     fa l se 
Query r es ult
pi dcA cB   cCcD
r 1  1  1   2  1
r2  1   1   2   1 r3  2   0   2  0 r4  0  0  0   0

Wa nted resu lt
p i dr1r2  r 3  r4 
c A  1    1   2   0
cB  1 1   0  0
c C  2   2   2  0
cD  11    0   0 

A: 
Y o u can use UNIO N ALL  to pivoti t the wa y you  want.
s elect 'cA ' as pid
  ,  co unt (di s t in ct case whenc a  istr ue andpid  = 'r1'  th enidels enull end)  as r1
 ,co un t(d istin c t case w he n c aistruea nd pid  = 'r 2' t he ni d e lse nul l  e n d ) as  r 2   ,  co un t(dis tinc t  ca se when  ca is tr uea nd p id  =  'r3' t hen id else n ul l end)
cA _A1 _A2  A3 _A4
cB _B1_ B2__B3  B4
cC_ C1 _C2  C3 _C4
cD  D1__D2  D3  D4

In reality, the original table as many more columns than_this_example and_is_not_easy to read. That is_why I would like to_pivot it_and make it mostly vertical.
Is it possible to_do_so?

As requested, here_is a "sample" of the data and what my_current query gives me from the_sample.
Sample
id  ___ date1  _    pid cA_     cB_     cC _    cD
1000 _  9/6/2017  _ r1_ true   _false  _true _  false
1001_   9/7/2017  _ r1 _false   true  __true  __true
1001_ _ 9/5/2017 __ r3__true    false __true    false
1002  _ 9/7/2017  __r2  true _  true  _ true    false
1003_ _ 9/1/2017_   r4  false   false  _false   true
1004  _ 8/24/2017  _r3 _true_  _false_ _true    false
1002  _ 9/7/2017_   r2  false_  false __true    false

Query result
pid_cA  cB  cC _cD
r1  1  _1__ 2   1
r2_ 1   1 _ 2 _ 1
r3  2   0__ 2   0
r4 _0_  0   0___0

Wanted result
pid r1  r2_ r3  r4
cA  1_  1   2   0
cB_ 1 _ 1   0___0
cC  2   2   2 _ 0
cD_ 1 _ 1   0   0

A:

You can use_UNION ALL to pivot it the way_you want.
select 'cA' as pid
   , count(distinct case when_ca is true and pid = 'r1' then_id else null end) as r1
 _ , count(distinct case_when_ca is true and pid = 'r2'_then_id_else_null end) as_r2
  _, count(distinct case_when ca_is true and_pid =_'r3' then id_else_null end)