Click here to Skip to main content
14,644,614 members
Rate this:
Please Sign up or sign in to vote.
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100