There seems to be no information from the member table. Therefore, select only the transaction table and specify conditionally.
select memberid, count(case when year(transdate) = 2015 then 1 end) as [2015], count(case when year(transdate) = 2016 then 1 end) as [2016], count(case when year(transdate) = 2017 then 1 end) as [2017] from transaction group by memberid order by memberid;
If you want to include members who do not have a transaction, you need a connection (external connection):
select m.memberid, count(case when year(t.transdate) = 2015 then 1 end) as [2015], count(case when year(t.transdate) = 2016 then 1 end) as [2016], count(case when year(t.transdate) = 2017 then 1 end) as [2017] from member m left join transaction t on t.memberid = m.memberid group by m.memberid order by m.memberid;
source share