Query Q1 gives me table in which there is total count of file received for particular date in a country.
Q1:
select
b.country,
CAST(a.ProcessDate AS Date) AS DATE,
count(a.ProcessDate) AS total
from Log a
LEFT JOIN Files b ON a.FileID = b.FileID
where a.ProcessDate BETWEEN '2022-10-01' AND '2022-10-30'
GROUP BY
b.Country,
CAST(a.ProcessDate AS DATE)
Now I want this table to transform into below table based on date column as header and also count of files should be distributed based on country like below table:
I need SQL for transforming Q1 to above table format. I was trying to use Pivot but not able to write correct sql which will give desire output.