Skip to content
Advertisement

Tag: sql

how to Avoid self-join in spark scala

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

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

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

Advertisement