My table looks (simplified) like this: It records filenames “File”; sometimes, a file (here BBB) is replaced by a newer one (here CCC”. First show all records, that have been replaced: OK, brings up line 2. Now I need to add a subquery column QQ, which shows the File of the substitute record, e.g. should bring: . My approach does
Tag: inner-join
SQL Query results into a already created table
I need some help getting the results from this query: To go into a table I have already created (Routegen). Routegen already has the columns (RouteNumber, DPS, Flats, Parcels). I’ve tried using SELECT INTO, but apparently I’m not doing it right because I can’t get the code to run after changing it. The main goal here is to compare then
SQL query is only returning one entry, when it should be returning several
I am creating a book tagging system and I am trying to call all the books with the same tag. My query is only turning up the first book, and not any of the following books with the same tag. Here is …
How to select rows in parent table based on a value in child table
Consider the following tables, what would be an efficient query to return 1 row for each order that has at least 1 child row with a specific warehouse code? I am using SQL Server 2016. Table: Orders …
Update column values with dynamically created JSON MySql
I have a Relationships table that looks something like this And 2 tables From and To I’m trying to update the JsonPair column with Json objects in the form {FromName: ToName}. So the resulting table would look like I’m a novice at SQL. I’m thinking that I should SELECT the names first, then use the result to put in the
SQL Complex update query filter distinct values only
I have 3 tables with following columns. Table: A with column: newColumnTyp1, typ2 Table: B with column: typ2, tableC_id_fk Table: C with column: id, typ1 I wanted to update values in A.newColumnTyp1 …
Get Name from characters that died on Episode3 with its killer
I have a doubt on this sql problem. Here is the tables. I currenly have all the characters names that died on Episode 3, but I don’t know how to get the character killers. Any idea? Select name from …
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 +——+-…
Select from many to many relations table
Given these tables: I would like to query scenarios with all the connected suites. results: **scenario** **suites** loginScenario loginSignup, endToEnd, smoke addToCart …
Query Optimization in SQL in given case
These are the given tables: Question is: Write a optimized query to find out the name of all the customerIDs who ordered coffee that originated from ‘Costa Rica’ or ‘Indonesia’. My attempt: My teacher says it can be optimized more but I don’t see any way. Please Help me out. Answer Rather than these nested in subqueries, I would recommend