Skip to content

Tag: sql

Two dimensional comparison in sql

DB schema There are rows with the same cryptid, I need to squash them to one row. So the cryptid becomes effectively unique. The complexity comes from the fact that I need to compare dates by rows as well as by columns. How to implement that? The rule I need to use is: status should be taken from the row

Why am I getting a duplicated column when doing this SQL query?

I am trying to do a set of queries in mySQL. In my final query I am trying to select the course_id column, but there are two columns with the title course_id and the exact same values, so I am encountering an error saying Query Error: Error: ER_NON_UNIQ_ERROR: Column ‘course_id’ in field list is a…

SQL – Merge two rows with similar values

I have the following table called areas in a PostgreSQL server: So basically it’s nearly duplicate entries that have the same name and code, but different id, shape and created timestamp. What I want is to merge those duplicate rows, but overwrite the “shape” and “created” fields…

MariaDb InnoDB deadlock while doing many inserts

I’m having deadlock issues with a MariaDB (10.0.27)if it’s under pressure. The database schema is basically a hierarchy and the leaf node causes this: This is how my leaf table looks like: I’m able to reproduce the deadlock with an input set that puts the system under pressure. With this, I&…

Joining back on the same table in SQL server

I have a table like below And the output I require is The match is defined on the basis of PO number. If PO number exists in both the sources then it should be match else only in AAP and only in SNW respectively. Can this be achieved? Thanks, Ani Answer or