Skip to content
Advertisement

SQL: Help creating a table based on another tables value

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 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

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.