I have the data as follow:
"Table" computer data
date | property | computer code
---------- -------- -----------
20160131 | companyA | 256584
20160131 | companyB | 987451
to e.t.c
20171020 | companyA | 157489
I want to count the number of computer in each company after 2017-Sep, so I use:
select
computer data
, count (case computer code when property='companyA' and date='20171001' then 1 else 0 end) as CMAnumber
, count (case computer code when property='companyB' and date='20171001' then 1 else 0 end) as CMBnumber
from
[data]
group by
computer data
order by
computer data
but it not work...
please help!!
I use SQL server 2014 Management Studio. and the data base from company system
and I want to show it like
date | CMAnumber | CMBnumber
20171001 | 200 | 210
20171002 | 230 | 207
ETC
sorry about that I am a fresh on SQL T.T