Search
 
SCRIPT & CODE EXAMPLE
 

SQL

sql roll up rows into columns

SELECT 
   SS.SEC_NAME,
   STUFF((SELECT '; ' + US.USR_NAME 
          FROM USRS US
          WHERE US.SEC_ID = SS.SEC_ID
          ORDER BY USR_NAME
          FOR XML PATH('')), 1, 1, '') [SECTORS/USERS]
FROM SALES_SECTORS SS
GROUP BY SS.SEC_ID, SS.SEC_NAME
ORDER BY 1
Comment

PREVIOUS NEXT
Code Example
Sql :: sql to linq 
Sql :: sql pivot rows to columns 
Sql :: mysql into outfile with headers 
Sql :: SQL SELECT TOP Equivalent in MySQL 
Sql :: how to select all fieldsin a soql query 
Sql :: android sqlite query join 
Sql :: SELECT DISTINCT on one column, with multiple columns returned, ms access query 
Sql :: oracle alter table add column 
Sql :: restore backup "text" postgresql command line 
Sql :: how to convert external table to managed table in hive 
Sql :: oracle undo tablespace schema 
Sql :: mysql default port number 
Sql :: change password in mysql 
Sql :: fk in insert mysql 
Sql :: mysql delete older duplicates 
Sql :: sql server set default value equal to auto increment 
Sql :: list mysql tables and views 
Sql :: select only distinct values from another table 
Sql :: get only one row in mysql 
Sql :: how to find sql server installation folder 
Sql :: frename oracle 
Sql :: azure check access to sql database 
Sql :: select year from dual oracle 
Sql :: stored procedure data to table 
Sql :: sql order 
Sql :: mysql show column type 
Sql :: alter database datafile maxsize 32g 
Sql :: mysql even numbers 
Sql :: in sql 
Sql :: wp sql to update admin email 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =