Skip to main content
Filter by
Sorted by
Tagged with
1 vote
2 answers
66 views

I'm exploring the use of ArrayAgg and I don't understand why 'histidine-[13C6,15N3]' doesn't occur before 'isoleucine-[13C6,15N1]' in this example: In [25]: for i in Infusate.objects.annotate(tns=...
hepcat72's user avatar
  • 1,225
0 votes
1 answer
201 views

I am using this function ARRAY_AGG in snowflake sql. It is giving me [] empty array many times as I have null values there. It is only giving it when i am using case when inside. how can i get just a ...
lil-wolf's user avatar
  • 382
-4 votes
1 answer
33 views

I've emp table which contains name & name2 field. I need the output in a single line. As i dont have unique id(emp_id) in this table, i am getting error as below :- ERROR: aggregate function ...
Gopal.anant's user avatar
1 vote
1 answer
126 views

I am using DuckDB, which should follows postgresql's syntax for the most part. I have two tables t_cons (~200k) and t_flows (~1.2M). For a row of t_cons there are many t_flows that match asset, year, ...
Abel Siqueira's user avatar
2 votes
2 answers
108 views

I have a query in Snowflake that produces json output in rows. 29,000+ rows. I am using this query to create records in an MDM system. However, this ingestion process is a bit inefficient and costly. ...
Scott J's user avatar
  • 25
3 votes
1 answer
104 views

Below is the postgres table table1: CREATE TABLE table1 ( id INT PRIMARY KEY, name TEXT, skills JSON ); with below 3 rows inserted: INSERT INTO table1 (id, name, skills) VALUES (1, 'Alice', ‘[ ...
overexchange's user avatar
0 votes
2 answers
424 views

I have a database design with multiple many-to-many relationships, and am trying to write a SELECT statement that retrieves a result set with ONE ROW PER USER. To do this, I'd like to aggregate the ...
wdc92's user avatar
  • 111
0 votes
1 answer
317 views

I have a table in snowflake that has three different columns being used as name type/values. These need to be mapped in an MDM tool using json. Of course, I cannot use the same attribute name more ...
Scott J's user avatar
  • 25
0 votes
2 answers
296 views

For example I have this model: class Parent(models.Model): name = models.CharField(max_length=255) class Child(models.Model): parent = models.ForeignKey(Parent, on_delete=models.CASCADE) ...
Ivan's user avatar
  • 95
2 votes
1 answer
2k views

We can use ARRAY_AGG aggregate function to generate an array from data. The goal is to find a way to limit the input to specific number of entries like ARRAY_AGG(...) WITHIN GROUP(... LIMIT 3) without ...
Lukasz Szozda's user avatar
4 votes
1 answer
1k views

ARRAY_AGG function omits NULL by definition. The requirement is to generate array with the following format: SELECT [NULL, 'a1', 'a2', 'a3', NULL] -- [ undefined, "a1", "a2", ...
Lukasz Szozda's user avatar
1 vote
1 answer
67 views

I need to combine the data of 2 tables, both has the same structure Table 1: key A.a A.b 1 2 2 3 3 4 4 2 1 1 table 2 : key A.a A.b 1 5 5 6 6 ...
Hbaieb Ahmed's user avatar
-1 votes
1 answer
451 views

I have a table containing the following fields: email - logged user email allowed_id - A ID of another User The table contains multiple entries for the same email, each one containing a different ...
andrepz's user avatar
  • 481
1 vote
2 answers
968 views

I have a BigQuery SQL below. The source table is aggregated from another table and field x contains distinct values. To further aggregate on field name, the query unnests x and uses array_agg(distinct ...
ningl's user avatar
  • 329
0 votes
1 answer
72 views

when a person pings or calls, we should be able to show that data and if he doesn't do, it should show as null but when he makes multiple pings or calls, it is appending as multiple array. below is ...
jay's user avatar
  • 3
0 votes
2 answers
514 views

I have the below tables: team col_name type id string name string coach_id string player col_name type id string name string team_id string main_skill_id string coach col_name type id string name ...
Fred Hors's user avatar
  • 3,823
1 vote
1 answer
1k views

I'm trying to make a query in BigQuery with the nested ARRAY_AGG function (one inside the other), as follows: ARRAY_AGG( STRUCT( . . . . . ARRAY_AGG( ...
dimitri.marinho's user avatar
0 votes
1 answer
204 views

The initial query finds the languages applied for each feature_id and makes the result into an array. I want to count the number of languages in each area, per feature_id, per version (new and old). ...
danaburtono's user avatar
0 votes
1 answer
47 views

Let's say I have the following django model: class Tag(models.Model): key = models.CharField(max_length=64, unique=True) class Site(models.Model): key = models.CharField(max_length=64, ...
jlandercy's user avatar
  • 11.6k
0 votes
1 answer
58 views

I am trying to query 3 tables to create one data set with master item data, transaction data and then serial numbers/locations. My left table is a unique key for each item mentioned once, then the ...
Greg Brown's user avatar
1 vote
1 answer
261 views

In a Postgres 11 database, I've got two arrays in two views which are joined to MAIN table: vw_ideas_role_direction_mappings.user_direction_id - array (like {101,103,} or {101,103} or {101,} or {101,,,...
Gerzzog's user avatar
  • 309
0 votes
0 answers
360 views

When using Array_agg, it returns the same values in different orders. I tried using distinct in a few places and it didn't work. I tried using an order before and after the array and it would fail or ...
Mike N Excel's user avatar
0 votes
1 answer
1k views

I am trying to write an SQL query using CASE where I want to return the values from the campaign table of the selected row when on two cases: The current time is between the start date and end date, ...
jabepa's user avatar
  • 61
1 vote
2 answers
4k views

I'm using postgres and I try to make my request with array_agg in knex, but I have the error: "message": "Expected 1 bindings, saw 0" Does anyone know where this error may come ...
poumchakaa's user avatar
0 votes
2 answers
2k views

Suppose I have a table like the following user score_1 score_2 score_3 1 100 80 100 1 80 null 80 2 95 90 65 I would like to aggregate the 3 scores columns into an array. The result will look like (the ...
Ryan's user avatar
  • 249
2 votes
3 answers
2k views

I use PostgreSQL 14 to manage a table which stores updates to a table of medics: users can update the first name, last name, and or/ the age of the medic. A field which was not touched by an update ...
Frerich Raabe's user avatar
0 votes
0 answers
541 views

I have the following SQL that produces a list of values: SELECT x / 100e0 FROM UNNEST(sequence(1, 100, 1)) t(x) # _col0 1 0.01 2 0.02 3 0.03 ... ... 100 1 I'm trying to aggregate the results to get an ...
Shlomi Schwartz's user avatar
1 vote
1 answer
2k views

The statement works for me: SELECT e.id, e.title, array_agg(d.start_date) date, array_agg(d.id) ids FROM event e JOIN event_date d ON e.id = d.event_id GROUP BY e.id I receive the results id title ...
olek07's user avatar
  • 593
-1 votes
1 answer
667 views

I am working with BigQuery tables that can have many levels of nested repeated record fields, as shown in the example. I need to make a select on the given table, extract only some fields and ignore ...
Boschi Francesco's user avatar
3 votes
2 answers
2k views

I am working with postgres. I want to fetch multiple fields using array_agg in sqlalchemy. But I couldn't find examples of such use anywhere. I made my request. But I can't process the result of ...
Alexander Goryushkin's user avatar
0 votes
0 answers
47 views

I have no clue how to do this. (Select Dane1.Name, Array_agg(Dane1.UpperCat) as "upper_category", count(Dane1.UpperCat) As data_count, dane1.room_id From (Select ...
Serpher's user avatar
  • 13
0 votes
1 answer
371 views

Based on the BigQuery best practice of using ARRAY_AGG() to obtain the latest record, here's how I'm getting the first, last minimum and maximum values of a field for a day. The data is reported ...
Martin Burch's user avatar
  • 3,010
0 votes
1 answer
331 views

I currently have the below query which perfectly works, but I would like to know if it can be optimized (perhaps avoid to UNNEST firstly and GROUP BY secondly and make transformations in one step). ...
JohnDu17's user avatar
-1 votes
1 answer
2k views

I created a new table with repeating records with duplicates. I am trying to find the most efficient way to deduplicate records as this will be run on a table with millions of records. If you using ...
Denis The Menace's user avatar
0 votes
1 answer
133 views

I have a query which in I joined twice the same table, i.e: left join tag tag1 [...] left join tag tag2 [...] I would like to have query with one column called tag which in I will have unique values ...
Tomasz's user avatar
  • 179
1 vote
1 answer
34 views

Let me first show you my table: INSERT INTO my_table(name, brand, source) VALUES ('Abc', 'Abc', 'Orig'), ('Auchan', 'Auchan', 'Orig'), ('Auchan', 'Auchan', 'Added'), ('dj-auchan-djd', 'Auchan', '...
Viktor Kachmaryk UA's user avatar
0 votes
1 answer
604 views

I need to process this table, divide the data into columns based on the value in exception_type in postgres. service_id, date, exception_type ... "2:11:CIST-100385-1-2023",2020-12-24,"2&...
Radek's user avatar
  • 3
0 votes
1 answer
444 views

I'ved got this string generated from sql query (basically using ARRAY_AGG and some cases to format the output) that looks like this {id:2,name_of_division:'super department1',attendance_radius:1000} ...
Axil's user avatar
  • 3,391
0 votes
1 answer
179 views

I am joining 2 tables, the join is left, and second table does not have all keys from the first, so that does produce NULLs on the right. How do I avoid them when grouping this into an array? For ...
MStikh's user avatar
  • 404
-1 votes
1 answer
875 views

I am joining several tables into one nested, and I was wondering if I could use a star expression, for example, SELECT t1.*, ARRAY_AGG(STRUCT(t2.*)) FROM t1 JOIN t2 on t1.col1=t2.col1 GROUP BY t1.* I ...
MStikh's user avatar
  • 404
0 votes
1 answer
627 views

I have a denormalised table and I want to simplify it using repeated fields inside of BigQuery. To illustrate what I am trying to do, I want to go from: |CustomerNumber|InvoiceNumber|InvoiceLineItem| |...
Clément Voisin's user avatar
0 votes
0 answers
178 views

Hi and thanks for your time I'm trying to run a process that backfills data between the partition dates of '2021-06-08' and '2021-06-10'. Each partition requires 10 days of data I want to produce a ...
Mark Aitkin's user avatar
2 votes
0 answers
66 views

i have two table casetemp and medicication_master patient has fields id name age sex medicineid 1 xyz 23 M 1,2 2 abc 20 f 3 medicine has fields id medname desc 1 crosin fever tab 2 etzaa shampoo 3 ...
user avatar
2 votes
2 answers
2k views

I have a data source with multiple similar columns that looks like this, with each question as a new column and the corresponding response: Original and I would like to convert it to use an array with ...
RJB's user avatar
  • 23
0 votes
2 answers
1k views

I have 2 tables: collections_books (collection_id, book_id) users_collections (user_id, collection_id, access) I'm using PostgreSQL. The following query gives me a list of book_ids grouped by ...
Siddiq Nx's user avatar
  • 122
0 votes
2 answers
225 views

I have a table which looks like this: record no firstType secondtype win? 1 X A 1 2 X A 0 3 X B 1 4 ...
David Kravitz's user avatar
4 votes
1 answer
6k views

class Language(models.Model): iso_code = models.CharField() class Publisher(models.Model) name = models.CharField() class Book(modle.Model): name = models.CharField() language = ...
sheesh's user avatar
  • 81
1 vote
2 answers
1k views

I manage to create a jsonb output, however I need to make it as object My current code create function extract_data() returns jsonb as $$ declare v_msgar text[]; v_result jsonb; ...
Moncici101's user avatar
0 votes
1 answer
943 views

How can i force a type in db:select(db::raw($query)) on PHP?? I have a really complex query that I'm getting data from, to do so I'm using DB::raw($query). I'm using the postgreSQL array_agg() ...
Felipe Colussi-oliva's user avatar
3 votes
1 answer
3k views

I have a list of students and parents and would like to group them into families using the student id's. Parents who share common student id's can be considered to be a family while also students who ...
Clint_A's user avatar
  • 546