There is a really complicated query, which I cannot wrap my head around alone. In the queried table there are 5 columns: PK_ID, which is the unique identifier of the value, ID, which connects the aggregated values in one group, the count, which says, how many value groups should be aggregated (if there aren’t enough, the group with such ID
Tag: recursive-query
MySQL – select distinct value from two column
I have a table with the following structure: How could I make a select statement on this table, which will return some rows of this table, where in each row, a specific id appears only one, indifferent on which column it is specified? For the above result set, I would like a query that would return: To give another example,
MySQL query to find all child elements
I have two tables : elements : id_element name elem1 CPV elem2 CBO elem3 CPV parenting (Which is referencing elements) id_element id_element_elements elem1 null elem2 elem1 elem3 elem1 elem4 elem2 Is there a query to find all the child elements from a single element in this case ? Looking for something like : id_element id_child elem1 elem2 elem1 elem3 elem2
Using SQL to group consecutive items that share a common status (dummy data included)
Given a table that has sometimes repeated statuses within a group (in this case “vehicles”), I want to consolidate those statuses into a single row and aggregate status_seconds. The data looks like this (I’ll include some TSQL below to select dummy data into a temp table to make it easy to work with this example) I want to, for example,
How to get the third level of a tree in SQL
I aim to list the forth generation of a family using SQL Server. Example family tree in the picture (id based) FAMILY TREE The tables I have are: Family +——+—————–+ | f_id | f_name …
Hierarchical SQL query to Athena
I’m trying to create a query in Athena that solves this problem: I have records that look like this which create a hierarchical structure, like a tree but with indeterminate children. I have more than one root, that is, more than one element that is not children of anyone. I want to get the complete structure for one of them.
Calculate a column value backwards over a series of previous rows/RECURSIVE/CONNECTED BY
need your help. I guess/hope there is a function for that. I found “CONNECT DBY” and “WITH RECURSIVE AS …” but it doesn’t seem to solve my problem. GIVEN TABLES: Table A +——+-…
How can i find all linked rows by array values in postgres?
i have a table like this: I want to find out which rows are in a group together. In this example 1,2,4 are one group because 1 and 2 have a common element and 2 and 4. 3 and 5 form a group because they have a common element. 6 Has no common elments with anybody else. So it forms
recursively creating multiple rows for every date between two dates in one row
I have staff holidays (rdos) stored in a single row, I am very close to recursively expanding them to show a full row for each day of leave. Running this on Postgres Database version 10.10 Data Set: My query currently: I am getting duplicate regressions and unwanted cross matches. Any ideas? I have seen similar solutions that rely on a
how i can get all products from parentid in SQL Server?
I have a category table to name TBL_category And includes the following fields: nid i identity field and i have a production Table TBL_Productions and foreign key is to nid And includes the following fields: productid is identity My question is: How can I display all products, when user selected mobile category ? I have nothing to do with the