ALTER PROCEDURE [dbo].[SpInvoiceSel]
AS
BEGIN
Declare @json varchar(MAX)
SET @json = (
select (
select InvoiceId as 'invoiceId',
i.CustomerId as 'customerId',
o.OrganizationName as 'organizationName',
(p.FirstName + p.LastName) as 'fullName',
sum(i.TotalRate) as 'totalrate'
from Invoice as i
inner join Customer as c
on c.CustomerId = i.CustomerId
inner join Organization as o
on o.OrganizationId = c.OrganizationId
inner join Employee as e
on e.EmployeeId = i.EmployeeId
inner join Person as p
on p.PersonId = e.PersonId
group by InvoiceId,i.CustomerId,i.EmployeeId,p.FirstName,p.LastName,i.TotalRate,o.OrganizationName
FOR JSON PATH, include_null_values
) as 'data' for json path, without_array_wrapper
)
select @Json as 'Json'
END
"Nathan field and Robert Plant are in different column" Now i need both of them in a single row