I have this query for which I want to remove aggregate function because I have multiple rows and the column names are dynamically created in DB.
SELECT [Date From],[Date To],[Vehicle Name],[Vehicle Register No.],[Mileage],[Amount],[Notes],[Approved By] from
(
select FieldData, FieldName from GLVoucherTransDetailView
) x
pivot
(
max(FieldData)
for FieldName in ([Date From],[Date To],[Vehicle Name],[Vehicle Register No.],[Mileage],[Amount],[Notes],[Approved By])
) p
This result is aggregate and it has multiple rows to return.
Date From Date To Vehicle Name Vehicle Register No. Mileage Amount Notes Approved By
28/12/2021 31/01/2021 Nissan Urvan 23423 43 5000 test 2 G1531
How to get multiple rows. Appreciated if anyone could help please.