![](/img/trans.png)
[英]How to merge multiple rows into one row with filtering rules in SQL Server
[英]How to merge multiple rows into one row in sql
你能幫我提供一個示例查詢,顯示如何在 sql 中將多行合並為一行嗎?請找到附件中的圖像。 示例輸入和 output
謝謝
這里第 2 列和第 3 列具有相同的字符串值 t1,t2、t3 和 t4 具有相同的值,並且列 1(父類)對於字符串 t1、t2、t3、t4 具有相同的名稱(AAA)。 如何將多行合並為兩行enter image description here
select max(cloumn1),cloumn2,cloumn3
from tablename
group by cloumn1;
試試這個
select * from
(select column1,column2,lead(column3) over (order by column1) as column3 from table1
) a
where column2 is not null
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.