samedi 2 juillet 2016

how to display data one table mysql based on some category

I want to display count of data of two category on single display

my table like below :

table : funding
area        client      Donatur
-----------------------------------------
A        Ox      Mr.X
A        Pr      Mr.Y
A        Qs      Mr.Z
A        Ts      Mr.Z   
B        Rt      Mr.X
C        Ss      Mr.X   
C        Sa      Mr.Z   

I want to display data to count based on area and donatur in on table like bellow

Donatur     Count of Area   Count of Client
--------------------------------------------------------
Mr.X          3             3
Mr.Y          1             1
Mr.Z          2             3

I have try to create query like below :

select count(client),count(area) from funding group by area,donatur

But i don't get any right number on one side, the result like below , same on both of them. It' should be like above

Donatur     Count of Area       Count of Client
--------------------------------------------------------
Mr.X          3             3
Mr.Y          1             1
Mr.Z          2             2

Aucun commentaire:

Enregistrer un commentaire