I am pulling data from a Teradata table and creating a dataset with last 4 months of data. But now, I have to calculate the number of patients visited each month in each department in last 4 months and create a dataset to load to another table. Also, I need to have those column names as mnth1, mnth2, mnth3, mnth4 for last 4 month in sequence based on the months. I have the sample data for have and want. Any help is highly appreciated. Thanks have: dt dep_cd dep_type patient ID 12/5/2019 A1 LP 65785 1/6/2020 A1 LP 39876 2/3/2020 A1 LP 89765 1/5/2020 A1 LP 36543 1/20/2020 A1 LP 33876 12/14/2019 A1 LP 20987 12/14/2019 A1 LP 20988 12/16/2019 A1 LP 21876 11/16/2019 A2 RP 91087 11/20/2019 A2 RP 76509 12/15/2019 A2 RP 34987 1/5/2020 A2 RP 54763 12/18/2019 A2 RP 45908 12/25/2019 A2 RP 66754 12/29/2019 A2 RP 51432 want dep_cd dep_type mnth1 mnth2 mnth3 mnth4 today_dt A1 LP 0 4 3 1 3/13/2020 A2 RP 2 4 1 0 3/13/2020
... View more