ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Merge two Rows in single Row with new column name in SQL Server<p>Hi <a class="username" rel="varun.p"> varun.p</a>,</p> <p>Refer below sample query.</p> <p><span style="text-decoration: underline;"><strong>SQL</strong></span></p> <pre class="brush: sql">DECLARE @tblQuantity AS TABLE(SR_No INT, Particulars NVARCHAR(MAX),IT_CODE NVARCHAR(MAX), UOM NVARCHAR(MAX),Opening_stock_Quantity INTEGER) INSERT INTO @tblQuantity VALUES(1,&#39;PPC TRADE YELLOW RED STRIP (ULTRATECH CUNNAR)&#39;,&#39;MMI00A001569&#39;,&#39;PCS&#39;,1000.00) INSERT INTO @tblQuantity VALUES(2,&#39;PPC TRADE YELLOW RED STRIP (ULTRATECH CUNNAR)&#39;,&#39;MMI00A001569&#39;,&#39;PCS&#39;,35000.00) SELECT TOP 1 SR_No ,Particulars ,IT_CODE ,UOM ,Opening_stock_Quantity ,(SELECT TOP 1 Opening_stock_Quantity FROM @tblQuantity ORDER BY SR_NO DESC) Opening_stock_Other_Quantity FROM @tblQuantity</pre> <p><span style="text-decoration: underline;"><strong>Output</strong></span></p> <table border="1"> <tbody> <tr style="height: 15.0pt;"> <td style="height: 15.0pt; width: 48pt;" width="64" height="20"><strong>SR_No</strong></td> <td style="width: 48pt;" width="64"><strong>Particulars</strong></td> <td style="width: 48pt;" width="64"><strong>IT_CODE</strong></td> <td style="width: 48pt;" width="64"><strong>UOM</strong></td> <td style="width: 48pt;" width="64"><strong>Opening_stock_Quantity</strong></td> <td style="width: 48pt;" width="64"><strong>Opening_stock_Other_Quantity</strong></td> </tr> <tr style="height: 15.0pt;"> <td style="height: 15.0pt;" align="right" height="20">1</td> <td>PPC TRADE YELLOW RED STRIP (ULTRATECH CUNNAR)</td> <td>MMI00A001569</td> <td>PCS</td> <td align="right">1000</td> <td align="right">35000</td> </tr> </tbody> </table>https://www.aspforums.net:443/Threads/165842/Merge-two-Rows-in-single-Row-with-new-column-name-in-SQL-Server/https://www.aspforums.net:443/Threads/165842/Merge-two-Rows-in-single-Row-with-new-column-name-in-SQL-Server/Mon, 08 Jul 2019 07:46:15 GMT