I am trying to work out a query for a transaction table with data as shown below:
| Dept | Employee | TransactionDate | Event |
|---|---|---|---|
| dept1 | emp1 | 2022-05-20 | abgd |
| dept1 | emp1 | 2022-05-20 | ggg |
| dept1 | emp1 | 2022-05-20 | hdfh |
| dept2 | emp2 | 2022-01-26 | 3fdfds |
| dept2 | emp2 | 2022-01-26 | dsfsd |
| dept2 | emp2 | 2022-01-26 | 554fsds |
| dept2 | emp2 | 2022-01-26 | gg32 |
| dept2 | emp2 | 2022-01-26 | fd4gfg |
I would like to list the count the no. of times the Dept+Employee+TransactionDate is repeated for each event as shown below:
| Dept | Employee | TransactionDate | Event | count |
|---|---|---|---|---|
| dept1 | emp1 | 2022-05-20 | abgd | 3 |
| dept1 | emp1 | 2022-05-20 | ggg | 3 |
| dept1 | emp1 | 2022-05-20 | hdfh | 3 |
| dept2 | emp2 | 2022-01-26 | 3fdfds | 5 |
| dept2 | emp2 | 2022-01-26 | dsfsd | 5 |
| dept2 | emp2 | 2022-01-26 | 554fsds | 5 |
| dept2 | emp2 | 2022-01-26 | gg32 | 5 |
| dept2 | emp2 | 2022-01-26 | fd4gfg | 5 |
I am looking a way to get the expected view. If it's possible with a single sql query?
Any pointers will be appreciated.