I am new to SQL and am currently doing a project on MSQL 2019. I have one table with a list of codes mapping a “Loss ID” to a Reason. Now I have another table that just gives you the number of the Loss ID but not the text version of it. How can I create a table that will
SQL aggregation based on time and location for Sankey graph
I have a situation where I’m trying to get data to populate a Sankey graph. I have the data with timestamp and the location of the person when captured by the system. The normal case is when a person location changes and in that case, “from” should be that location and “to” should be that person’s next entry provided it’s
SQL Multiple join from 2 table to 1
I want to join from 2 table to 1. I have tried it multiple times but I can’t figure out the correct code. The name ‘Edvard Supica’ which is the full_name from suser table I want to be on the place of User ID and in 1 record. Answer If you’re joining both machines and susers on workbook, you can
T-SQL Calculating Time Quarters
I would like to parse this record across quarter buckets and the length spent in each quarter bucket. Answer Just another option … BRUTE FORCE Example or dbFiddle Results
Create a “flag” table that references unique IDs in 3 different tables
Oracle SQL I have account IDs in 3 different tables (one column per table). They sometimes repeat within the table’s column. Some of the distinct account IDs in Table 1 also appear in Table 2. Some appear in all 3 tables. There is no mutual exclusivity requirement across the tables (i.e – an account ID can appear in any combination
Consolidate Rows with SQL
Trying to consolidate test results so that each test is in one row. Database I am pulling from has an answer result per row. Sample Data: Student Name Test Name Question Attempt Answered Correctly (0 = no, 1= yes) Mary Intro Assessment 1 1 Mary Intro Assessment 1 0 Mary Intro Assessment 1 1 Joseph Intro Assessment 1 1 Joseph
SQL Inner join with sum and null value
The table below is an extract of a larger set of data In my scenario Column 2 is null when is the “parent” record (Column 1 = AB1 and Column 2 is NULL) and as you can see the following 2 “child” records under Column 2 have AB1 as identifier which matches the AB1 from Column 1, what I want
Oracle Hierarchy – How to get a particular level record in a query?
We have the following structure for Organizations. Query returns the result What I’m trying to do is let’s say I need to get the Department (Information Technology Department) of org_id 4 (Database Unit), how should I build the query for that? Currently we built a function that returns the department id which basically loops until it reaches the DEP parent.
How to find duplicate values according multiple columns and show both
I try to find another examples, but I have not been able to find one that can help me I am currently trying to find if the value in the STR_ROUTE column is in the STR_STREET column, as shown in the following example ID STR_ROUTE STR_STREET 1 MAIN Can 2 AV CAL 3 CLL CLL 4 STR VAL 5 VAL
SQL make 2 columns into 1 from 1 table keep all rows in SELECT query
I am dealing with a DB whose transaction table could have been split up into 2, but dev team decided it was not worth it. Now I want to retrieve the transactions and their dates. Problem is : table includes 2 different types of transactions, meaning: I have 2 date columns : “transaction_date” and “beta_transaction_date” (I am modifying the names