Hi,
Here is my table and the expected result.
I tried this query, but the output for checkout shows as 3 instead of 1 for AB company, which is not my expected result. The problem is at only at the checkout column.
select person, sum(case when [checkin date] = '20180503' and description != 'Room Change' Then 1 else 0 end) as checkin, sum(case when [checkout date] = '20180503' Then 1 else 0 end) as Checkout, sum(case when [checkin date] =< '20180503' and [checkout date] > '20180503' Then 1 else 0 end) as POB
from table
group by organization