Questions tagged [string-aggregation]

This tag is intended for SQL questions where multiple string (character) values should be aggregated into a single value using GROUP BY. The equivalent of sum() - just for strings.

The ISO/IEC SQL standard function for this is LISTAGG, but several DBMS:es have their own string aggregation functions:

386 questions
4
votes
4 answers

comma-separated list as a result of select statement in Oracle

I have a table named "person". It contains person's id and it's parent id (only one parent is possible). As a result of a query, I want a table with first column - a person id, and a second column - a list of it's children id's. How exactly to do…
brain_damage
  • 955
  • 6
  • 20
  • 29
4
votes
2 answers

From multiple rows to single column in Postgres

I am using Postgres 9.5 via pgAdmin 4 with read only access and im trying to write a select query that converts data from this form: +----------+-------------------+--------------------+----------------+ | username | filters | …
Dabbous
  • 167
  • 4
  • 13
4
votes
2 answers

SYS_CONNECT_BY_PATH with CLOB

I have an ORA-01489: result of string concatenation is too long error executing this query on a Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production, PL/SQL Release 11.2.0.4.0 - Production, CORE 11.2.0.4.0 Production, TNS for…
Nuñito Calzada
  • 4,394
  • 47
  • 174
  • 301
4
votes
1 answer

PostgreSQL - JOIN on string_agg

I have three tables. Students student_id | name 1 Rhon Subjects subject_id | subject_name | student_id 1 Physics 1 2 Math 1 Grades grade_id | student_id | subject_id | grade 1 1 …
4
votes
2 answers

String Aggregation of potentially empty fields without FILTER in postgres.

In Postgres I am trying to included a comma separated list of linked ip addresses to a particular server in the result rows of server data. Initialially I used the FILTER functionality which seemed ideal for my purposes STRING_AGG(ipadd, ',') FILTER…
JamesA
  • 365
  • 3
  • 11
4
votes
2 answers

Concatenate Over Oracle

This is a sample table data Fruit Number Apple 1 Apple 2 Apple 3 Kiwi 6 Kiwi 10 I try to concatenate the table column values to get the following Fruit Number Apple 1-2-3 Kiwi 6-10 Is there a way to query this or store…
Sailormoon
  • 259
  • 1
  • 5
  • 23
4
votes
1 answer

emulate group_concat in MSSQL, ambiguous column name?

I am currently trying to simulate the group_concat function in MySQL to MSSQL. I have followed code formats found in here and here. The problem is, when I try to execute the query, I get the message Ambiguous column name for my column RoleID. Here…
JamesP
  • 195
  • 1
  • 3
  • 17
4
votes
2 answers

Oracle Function: Replicate wm_concat

I currently am working on a project within Crystal Reports that refuses to use the undocumented function WM_CONCAT, which is allowable within Oracle 10g. Here is the WM_CONCAT header information WM_CONCAT(p1 IN VARCHAR2) RETURN VARCHAR2 To use…
contactmatt
  • 18,116
  • 40
  • 128
  • 186
4
votes
3 answers

SQL Server equivalent to GROUP_CONCAT()

I have this database: And I need to get the following data for each Client: Client Name Contract Name(s) Project(s) Employees who logged hours to a project from the first day of the current month until the last day of the current month Total…
Joe Boris
  • 487
  • 3
  • 8
  • 15
4
votes
1 answer

SQL Server 2000 equivalent of GROUP_CONCAT function

I tried to use the GROUP_CONCAT function in SQL Server 2000 but it returns an error: 'group_concat' is not a recognized function name" So I guess there is an other function for group_concat in SQL Server 2000? Can you tell me what it is?
4
votes
2 answers

How to find count and names of distinct characters in string in PL/SQL

I'm quite new to PL/SQL and I need to get the names and count of the distinct characters in a string. E.g. if I have a string str="helloexample", I need to get output of distinct characters in str, i.e. heloxamp. How can I do this?
iAmLearning
  • 1,153
  • 3
  • 15
  • 28
3
votes
1 answer

How can I aggregate rows together according to a selected column using a pandas DataFrame

this is my first question in Stack Overflow. I will water down the problem that I have at the moment. I am trying to clean a dataset for a User-based collaborative filtering recommendendation system. Here's an oversimplication of the dataset I have…
3
votes
2 answers

sql, big query: aggregate all entries between two strings in a variable

I have to solve this problem within bigQuery. I have this column in my table: event | time _________________|____________________ start | 1 end | 2 random_event_X | 3 start | 4 error_X | 5…
Nine
  • 115
  • 9
3
votes
1 answer

Alternative to STRING_AGG in with SQL

I have a table as below | activityName | UserID | deviceID | createdDate | |------------------------------------------------------------| | ON | 1 | adddsad |2020-01-09 00:02:59.477 | | OFF | 1 | adddsad …
Hardik Mer
  • 824
  • 4
  • 14
  • 26
3
votes
3 answers

SQL Query multiple users who started on the same date

I've got a table something like this: UserID TeamID StartedDate 36202 1213 27/11/2019 9:00 36203 1213 1/11/2019 10:30 36203 1207 24/11/2019 10:00 36205 1207 21/11/2019 9:15 36203 1213 1/11/2019 10:30 36214 1217 …
Mo_Dlg
  • 73
  • 1
  • 9
1 2
3
25 26