Dear experts,
kindly help me to get data like below

from

Select customer_number [Customer Number],customer_Name [Customer Name],Collector [Collector],clrno [CLR No],Clrdate [CLR Date],commitment_amount [Commitment Amount]
,Commitment_Date [Commitment Date] ,Receipt_Date [Receipt Date]
From (
Select
cm.customer_number,cm.customer_name,c.name as Collector,h.header_id clrno,Format(h.creation_date ,'dd-MMM-yyyy') Clrdate,cml.commitment_amount
,Format(cml.commitment_date ,'dd-MMM-yyyy') Commitment_Date ,Format(cml.receipt_date ,'dd-MMM-yyyy') Receipt_Date
From CLRHdrs h
Inner join CustomerMasters cm on h.customer_id=cm.customer_id
Inner join ClrCommitmentLogs cml on h.header_id=cml.clr_id
inner join Collectors c on h.collector_id=c.collector_id
Where -- h.header_id=156000
Vishal JoshiPosted Mar 4, 2024, 5:42 AM
Hello,
To convert rows to columns you can use PIOVT. Check the below query for your reference.
Thanks
Vishal Joshi
Mukesh NailwalPosted Mar 4, 2024, 10:03 AM
Hello, you can refer ArunKumar's article on C# Corner to convert rows into columns.. Here is the link
https://www.c-sharpcorner.com/code/1267/converting-rows-into-columns.aspx
Thanks
Prasad RaveendranPosted Mar 3, 2024, 7:11 PM
Here's an example of how you can modify your query to achieve that:
This assumes that
commitment_amountis the value you want to pivot and that you want to pivot based on theheader_idvalues. Adjust the column names and values accordingly based on your specific requirements. If you have multiple header_ids, you can add them inside theINclause of thePIVOTstatement.Rajanikant HawaldarPosted Mar 3, 2024, 5:28 PM
Check below articles, might help you to resolve your issue by understanding through...
https://www.c-sharpcorner.com/code/1267/converting-rows-into-columns.aspx
https://www.c-sharpcorner.com/UploadFile/suthish_nair/convert-rows-to-columns-in-sql-server-20082005/