I have a query that looks like this:
SELECT OrganizationName, OrganizationID, ReceivableStatus, InvoiceFee
FROM v_InvoicesFreelanceOutstanding
ORDER BY Organizat
PIVOT sucks. It has horrible syntax and isn't a PIVOT in the pivot table sense i.e. you have to know exactly how many columns will result in advance.
It's probably easier to do a cross-tab report.
SELECT
OrganizationName,
OrganizationID,
SUM(CASE WHEN ReceivableStatus = '30-60 days' THEN InvoiceFee ELSE 0 END) AS [30 - 60 Days],
SUM(CASE WHEN ReceivableStatus = '60-90 days' THEN InvoiceFee ELSE 0 END) AS [60 - 90 Days],
SUM(CASE WHEN ReceivableStatus = '90-120 days' THEN InvoiceFee ELSE 0 END) AS [90 - 120 Days]
FROM
v_InvoicesFreelanceOutstanding
GROUP BY OrganizationID