string-aggregation Questions

11

Solved

The following query returns the results shown below: SELECT ProjectID, newID.value FROM [dbo].[Data] WITH(NOLOCK) CROSS APPLY STRING_SPLIT([bID],';') AS newID WHERE newID.value IN ('O958...
Inshore asked 29/5, 2018 at 16:33

6

Solved

I'm using the STRING_AGG function in SQL Server 2017. I'd like to create the same effect as COUNT(DISTINCT <column>). I tried STRING_AGG(DISTINCT <column>,',') but that is not legal syn...
Orthography asked 2/8, 2018 at 5:52

2

Solved

I need to combine texts by group. I found a function called STRING_AGG. select c.id , c.bereichsname , STRING_AGG(j.oberbereich,',') oberBereiches from stellenangebote_archiv as j join bereiche as...
Sherry asked 19/9, 2022 at 11:55

3

My query is below: select u.Id, STRING_AGG(sf.Naziv, ', ') as 'Ustrojstvena jedinica', ISNULL(CONVERT(varchar(200), (STRING_AGG(TRIM(p.Naziv), ', ')), 121), '') as 'Partner', from Ugovor as...
Markova asked 26/2, 2018 at 9:59

9

Solved

I have a table and I'd like to pull one row per id with field values concatenated. In my table, for example, I have this: TM67 | 4 | 32556 TM67 | 9 | 98200 TM67 | 72 | 22300 TM99 | 2 | 23009 TM99...
Waterside asked 1/4, 2010 at 14:9

4

Solved

I have a table: CREATE TABLE tblproducts ( productid integer, product character varying(20) ) With the rows: INSERT INTO tblproducts(productid, product) VALUES (1, 'CANDID POWDER 50 GM'); INSER...
Papery asked 23/7, 2014 at 9:30

4

Solved

DROP TABLE IF EXISTS items; CREATE TABLE items (item varchar(20)); INSERT INTO items VALUES ('apple'),('raspberry'); SELECT STRING_AGG(item, CHAR(13)) AS item_list FROM items; How do I get a li...
Emirate asked 11/12, 2019 at 10:33

12

Solved

I'm trying to migrate a MySQL-based app over to Microsoft SQL Server 2005 (not by choice, but that's life). In the original app, we used almost entirely ANSI-SQL compliant statements, with one sig...
Tinware asked 16/1, 2009 at 18:14

3

I'm migrating some SQL Server 2008R2 queries to Postgresql 9.0 and I have some trouble with it. Here's the SQL Server query: stuff((select ', '+p.[NAME] as 'data()' from BPROVIDERS_PROVIDER p, BO...
Conchiferous asked 2/1, 2013 at 9:24

2

Solved

Can anyone help me make this query work for SQL Server 2014? This is working on Postgresql and probably on SQL Server 2017. On Oracle it is listagg instead of string_agg. Here is the SQL: select ...
Prostration asked 19/3, 2018 at 10:47

2

Solved

I'm using Postgres and I have the following schemes. Orders | id | status | |----|-------------| | 1 | delivered | | 2 | recollected | Comments | id | text | user | order | |----|---------|------...
Ayr asked 3/8, 2020 at 20:57

2

Solved

I'm using redshift and would like to create a comma separated list of columns. I'm trying to grab the column names from information schema using listagg: SELECT listagg(column_name,',') within gr...
Customary asked 22/4, 2016 at 1:55

2

Solved

Anyone knows if String Aggregation in sqlite is possible? If i have an animal column with 5 rows/datas, how can i combine them so that the output would be in one field 'dog','cat','rat','mice','mo...
Neutral asked 18/8, 2010 at 18:16

14

Solved

I am looking for a way to concatenate the strings of a field within a group by query. So for example, I have a table: ID COMPANY_ID EMPLOYEE 1 1 Anna 2 1 Bill 3 2 Carol 4 2 Dave a...
Maihem asked 4/9, 2008 at 14:27

1

Here is my code in sql server 2016 insert into @entdef_queries(entitydefid,squery) select A.entitydefid , ( select String_agg(cols,ioperator) from ( Select case when lower(b.metricdatatype)...
Bible asked 6/2, 2019 at 12:0

1

Solved

I have the following query: WITH cteCountryLanguageMapping AS ( SELECT * FROM ( VALUES ('Spain', 'English'), ('Spain', 'Spanish'), ('Sweden', 'English'), ('Switzerland', 'English'), ('Switz...
Mitchelmitchell asked 27/9, 2018 at 9:14

2

Solved

I have to replace the Oracle driver with the newest PostgreSQL. PostgreSQL doesn't know the function LISTAGG. I have to concat values by comma separated. What's the equivalent for the Oracle's func...
Mineral asked 10/4, 2015 at 9:11

5

I need a way to make a concatenation of all rows (per group) in a kind of window function like how you can do COUNT(*) OVER(PARTITION BY...) and the aggregate count of all rows per group will repea...

2

Solved

I try to create a generic function that can be used like this example of using the new string_agg built-in function on SQL Server 2017 the inside implementation can be something like the follow ...
Haletky asked 14/2, 2018 at 9:3

10

Solved

Would it be possible to construct SQL to concatenate column values from multiple rows? The following is an example: Table A PID A B C Table B PID SEQ Desc A 1 Have A 2 a nice A 3 day. B ...
Winola asked 13/1, 2011 at 23:34

11

Solved

I have 3 tables called: Applications (id, name) Resources (id, name) ApplicationsResources (id, app_id, resource_id) I want to show on a GUI a table of all resource names. In one cell in each r...
Apetalous asked 30/11, 2009 at 5:31

2

Solved

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 seeme...
Survance asked 8/10, 2015 at 10:47

4

I have this query : (SELECT OBJECT_ID from cr_object_group_entries_vw where object_group_id IN (SELECT ITEM FROM TABLE(CR_FN_SPLIT_STRING('28,56',',')))) that returns : But when I do : SELE...
Reba asked 21/5, 2013 at 16:27

1

Solved

Does anyone know if Firebird 2.5 has a function similar to the "STUFF" function in SQL? I have a table which contains parent user records, and another table which contains child user reco...
Hydrogeology asked 29/10, 2014 at 16:14

4

Solved

I know that in sql server we cannot use Group_concat function but here is one issue i have in which i need to Group_Concat my query.I google it found some logic but not able to correct it.My ...
Occurrence asked 11/7, 2013 at 10:54

© 2022 - 2024 — McMap. All rights reserved.