You don't provide any information about how your schema is, but I assume you have a Customer table and a Transaction table. Consider this example with 4 customers and 12 transactions.
Customers
| id | name |
|----|----------|
| 1 | Google |
| 2 | Facebook |
| 3 | Hooli |
| 4 | Yahoo! |
Transactions
| id | transaction_date | customer_id |
|----|------------------|-------------|
| 1 | 2017-04-15 | 1 |
| 2 | 2017-06-24 | 1 |
| 3 | 2017-07-09 | 1 |
| 4 | 2017-07-24 | 1 |
| 5 | 2017-07-23 | 2 |
| 6 | 2017-07-22 | 2 |
| 7 | 2017-07-21 | 2 |
| 8 | 2017-07-24 | 2 |
| 9 | 2017-07-24 | 3 |
| 10 | 2017-07-23 | 4 |
| 11 | 2017-07-22 | 4 |
| 12 | 2017-07-21 | 4 |
To count the number of transactions the last two months by each customer a simple group by will do the job:
select name, count(*) as number_of_transactions
from transactions t
inner join customers c on c.id = t.customer_id
where t.transaction_date > dateadd(month, -2, getdate())
group by c.name
This yields
| name | number_of_transactions |
|----------|------------------------|
| Facebook | 4 |
| Google | 3 |
| Hooli | 1 |
| Yahoo! | 3 |
To retrieve only customers that have a transaction with a transaction_date equal to today we can use an exists to check if such a row exist.
select name, count(*) as number_of_transactions
from transactions t
inner join customers c on c.id = t.customer_id
where t.transaction_date > dateadd(month, -2, getdate())
and exists(select *
from transactions
where customer_id = t.customer_id
and transaction_date = convert(date, getdate()))
group by c.name
So, if a row in the transaction table that has a transaction_date equal to today and the customer_id is equal to the customer_id from the main query include it in the result. Running that query (given that 24th July is today) gives us this result:
| name | number_of_transactions |
|----------|------------------------|
| Facebook | 4 |
| Google | 3 |
| Hooli | 1 |
Check out this sql fiddle http://sqlfiddle.com/#!6/710c94/13