Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i want to get ID of all rows (in a single column) on which aggregate function is applied.

for example

select sum(colData), IDofAllRows from table1
Posted
Updated 23-Dec-15 12:19pm
v2
Comments
CHill60 23-Dec-15 18:54pm    
Some sample data and your expected results would help us to help you. Use the "Improve question" link to add detail
jgakenhe 23-Dec-15 20:12pm    
So you want to aggregate results into 1 row. Oracle makes it easy, but SQL Server is not so easy. I am not sure what DBMS you're using, but the examples below should help.

Oracle: LISTAGG
https://oracle-base.com/articles/misc/string-aggregation-techniques

SQL Server: No function I'm aware of, here's some technigues
http://www.codeproject.com/Articles/691102/String-Aggregation-in-the-World-of-SQL-Server
https://www.simple-talk.com/sql/t-sql-programming/concatenating-row-values-in-transact-sql/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900