การต่อนำข้อมูลหลายๆแถวมาต่อกันให้เหลือแถวเดียว

Synnex

STRING_AGG ( expression, separator ) [ <order_clause> ]

<order_clause> ::=   

    WITHIN GROUP ( ORDER BY <order_by_expression_list> [ ASC | DESC ] )


Example

select receipt_id, STRING_AGG(receipt_item,',') within group (order by receipt_line asc)

from table_receipt

group by receipt_id

Comments

Popular posts from this blog

วิธีตั้งค่า NTP บน Primary Domain Controller

การตั้งเวลาระหว่าง Server และ Client

ตรวจสอบ Version และ Service Pack ของ SQL Server