Question:
Basically, I have a table that tells about type of communication to accounts(either by letter or email) like :ACOUNT_ID | TYPE_OF_COMM |
---|---|
1 | Letter |
1 | Letter |
3 | |
2 | Letter |
4 | |
4 | Letter |
and so on.. A query needs to be written that counts :
- the number of accounts that received letter only,
- the number of accounts that received mails only,
- the number of accounts that received both letters and mails
So the output of above should be :
Type_of_comms | Count of Accounts |
---|---|
Letters only | 2 |
EMail only | 1 |
both letters and mails | 1 |
Thanks in advance!
Answer:
I’m not familiar with Athena, but as long as it supports CTEs / subqueries, this should work:If you have better answer, please add a comment about this, thank you!