I have a DataFrame called product_relationship_current and I’m doing a self-join to retrieve a new DataFrame like bellow: First I’m giving it an alias so I could consider them like two different dataframes: And then I’m doing a self-join to get a new dataframe: But I’m looking for another way to do that without doing a self-join, so I don’t
Tag: sql
table only record one character of my form field
One of my tables from pgsql has a strange behaviour like the title says. Here are some screenshots: As you can see, the name zamdam must be record in the column “nom” in pgadmin instead of recording one letter for one column, here is the sql statement + server code : It was working well until I started to add
Find departments with no employees
We were given an assignment in class to provide at the minimum two different solutions to find departments, which don’t have any employees. As you can see from below I completed the task successfully. An additional solution is extra credit, which I like to get. Unfortunately, I can’t think of a third solution and was hoping someone can point me
MySQL – Join 2 tables and count number of entries
I’m trying to join 2 tables and count the number of entries for unique variables in one of the columns. In this case I’m trying to join 2 tables – patients and trials (patients has a FK to trials) and count the number of patients that show up in each trial. This is the code i have so far: The
Allocate groups by size, preliminarily rounded and grouped
You are given a database of notebooks that contains two tables. the table notebooksbrand contains data about the name of notebook brands. the table notebooksnotebook contains data about the name of the notebook, its diagonal, width, depth, and height, and has a link to the brand to which this model belongs. You need to select groups of notebooks by size.
SQL how to create a view with 2 sums of diferent tables, when those tables have diferent number of rows
I have 3 tables, “accounts” “charges” and “payments” I want to create a view with the account data the sum of the charges, and the sum of the payments, but payments have usually more records than charges for the same account when I create the view and GROUP BY charges end up “duplicated” like by the number of rows mismatch.
How to split a string which contains delimiter into multiple rows using OPENJSON function
I am trying to split the below string using OPENJSON function in SQL Server 2019: But the result is returned as: I want to display it as this: Thanks Answer This is where my thinking brings me. Note: Unexpected results of the “‘s are NOT balanced. Example or dbFiddle Results
Sequelize query. Multiple count depends on column name
I have working query: It returns total count for all columns that has code=1081 and 1082 in “Region” table. In “Region” table there is “code” row that has 5 different codes. It’s a primary key to GeograpicalAdministrativeAreas table. I need to calculate for each column separated amount (not only for 1081 and 1082 in total how it is now). So
Update statement with inner join on Oracle ORA-01427
ORA-01427: single-row subquery returns more than one row ORA-06512: at “SYS.DBMS_SQL”, line 1721 I need to do update with inner join in ORACLE Answer The script you provided above is going to update all rows in the table because you do not have a where clause. If you really want to update all rows in the table, then this should
SQL: Flattening multiple rows in ugly data
I’m working on a fairly odd scenario in which I’ve got to compensate for a client’s database that isn’t very well-ordered. The data (example below) concerns some products that have a main serial number (serial) and between 0 and 4 additional alternate serials (alt_serial). Unfortunately, neither of these columns is a primary key, and each alternate serial number produces an