395 questions
-1
votes
1
answer
85
views
What is the correct LISTAGG command for the equivalent STRING_AGG [duplicate]
We recently migrated the data from SAP HANA to Oracle. The database is Oracle 19c.
I need to know the corresponding Oracle 19c command for the below query. The below query is utilizing STRING_AGG. ...
0
votes
1
answer
130
views
Multiple STRING_AGG in one query
I have a dataset that looks like this:
Dummy table
The desired view I'd like is:
enter image description here
I have tried the STRING_AGG function, which works, but for only one column. See below for ...
1
vote
1
answer
261
views
Cannot perform an aggregate function on an expression containing an aggregate or a subquery with STRING_AGG
I am trying to query information from 2 tables. The PrimaryTable I simply want to return all columns from all rows in that table. The SupportTable I want to just get all of the ID's from that table ...
1
vote
1
answer
123
views
Using string_agg to create distinct groups by row
Consider 'Table 1' below:
id
x
1
A
1
B
1
C
2
B
2
C
3
A
I want to query Table 1 to produce the following:
id
x
grps
1
A
B, C
1
B
A, C
1
C
A, B
2
B
C
2
C
B
3
A
Using string_agg and grouping by id ...
0
votes
1
answer
3k
views
STRING_AGG with OVER() clause in SQL Server
Is there any equivalent of Postgres: STRING_AGG with OVER() or Oracle LISTAGG with OVER() in SQL Server? I would like to concatenate text values without grouping it, so I need STRING_AGG in analytical ...
0
votes
1
answer
106
views
Table column aggregation results in the same value duplicating multiple times in one cell
I have a set of tables aimed at representing a profile storage system. I have created a view that should display all the important parts of this profile, that being things like the name, email, number ...
0
votes
1
answer
40
views
Subquery and group by : Validation failed: mismatched input 'FROM' expecting <EOF>
I want to calculate the cost by multiplying a price with the quantity of my equipment.
My data are like that :
idnt_eqpm
prx_tot_net
prix_pump_ht
10954847
10
8
And I want this data :
idnt_eqpm
...
0
votes
1
answer
79
views
Oracle format String output from Aggregate Collect function
Below is my working Oracle query-
-- User-Defined TYPE
create or replace TYPE varchar2_ntt AS TABLE OF VARCHAR2(4000);
-- This works
select emp.DEPT_NAME,
CAST(
COLLECT(emp.EMP_ID ...
0
votes
1
answer
92
views
Oracle Collect function on Multiple Columns gives Error
Reference Tutorial-
oracle-developer.net
Below is my working Oracle query-
-- User-Defined TYPE
create or replace TYPE varchar2_ntt AS TABLE OF VARCHAR2(4000);
-- User-Defined FUNCTION
CREATE FUNCTION ...
0
votes
1
answer
61
views
ORACLE SQL Excluding results within Select (“Result of string concatenation is too long)
For the last couple of days my head is spinning around this issue and I am really hoping you can help me with this. So simplifying the issue. This is the table I already have:
ID
Message
Time
Zone
1
A
...
2
votes
1
answer
3k
views
Snowflake - LISTAGG with LIMIT
Snowflake allows to concatenate string across multiple rows by using aggregate/windowed LISTAGG function. Sometimes we just need first few occurrences per group. Similar to GROUP_CONCAT with LIMIT:
...
2
votes
3
answers
192
views
How to optimise a query with multiple subqueries for string aggregation?
This is my query:
SELECT
wp.WorkplanID,
STUFF((SELECT ', ' + ISNULL(ul.FirstName + ' ', '') + ISNULL(ul.LastName, '')
FROM UserLogin ul
INNER JOIN Vendors v ON ul....
0
votes
4
answers
104
views
How do I return identical values between two string aggregated columns in SQL?
I have 2 columns A & B in a SQL Server table that contain a string aggregated list of codes.
The codes in the lists are separated by a semicolon.
The string aggregated lists can take any length ...
-1
votes
1
answer
1k
views
SQL: Use STRING_AGG with condition
I have the following PostgreSQL query: (This is a Kata at codewars, you can find it at the following link: https://www.codewars.com/kata/64956edc8673b3491ce5ad2c/train/sql )
SELECT * FROM (
SELECT
...
-1
votes
3
answers
239
views
SQL concatenate row by row by date order with in group
I am looking for a way to concatenate the rows into a comma separated string.
Example:
I am looking for result as below where Result Seq column should concatenate the result column row by row values ...