Dummy data to illustrate my problem: So the data looks like: Table 1: category_id unit is_valid 1 a true 2 z true Table 2: category_id unit 1 a 1 b 1 c 2 d 2 e I want to update the is_valid column in Table 1, if the category_id/unit combination from Table 1 doesn’t match any of the rows in
SQL Server => How to use “case when” on multiple column to show a formula result based on a condition in the same line
I’m trying to provide an overall result of a formula ([CALCULATION]) and then in two extra columns ([NO_TENURE] & [TENURE]) the same calculation but using “CASE WHEN” to filter the information based on another column called [TENURE], everything in one single line like this: Right now is being shown this way: This is the code I’m using: I really appreciate
Using INSERT and UPSERT in SQLite trigger to update one table from another table?
I’m attempting to create a SQL database for an Auction company I work for. The issue I’m running into is creating triggers that update other inventory tables from the main inventory. I’ve tried quite a few different things, but can’t wrap my head around how to get this to work. The latest trigger I’ve attempted is as follows: Additional info:
Fill Null Values with Last Previous Value and add 1 as a continuous integer for every value going forward – Big Query
I have these two columns in Big Query: budget_id and activity: budget_id activity region execution window 000507_Corporate 507 Corporate 2022 000508_AMERICAS 508 AMERICAS 2022Q2 NULL NULL c b NULL NULL c b The budget_id comes from a Google Sheet which is manually inputted by a stakeholder. I’m trying to change this that going forward, I can automate this myself. Everything
Left join add matched rows in child table to an array in parent row (as JSON format)
I have the following two tables: My goal is to do a (left?) join and get all matching rows in the child table based on the FK in an array on the parent row and not inside the parent row itself on matching column names (see further down on desired output). Examples of values in tables: Parent table: Child table:
Replace OUTER APPLY
I want to replace some OUTER APPLYs in my SQL because they seem to be a little bit slow and eating resources () on a poor VPS. I have no idea what to use instead? LEFT OUTER JOIN (??) Here’s my code The query processor ran out of internal resources and could not produce a query plan. This is a
How to Use Queries to show records based on conditions
I have an SQL query that selects data based on uploaded and not uploaded this is the query am using to achieve the data above I want to go a step further and group the data into two columns. I want to get the labnames grouped using the uploadstatus that is 0 as Not Uploaded and the ones having 1
How to create a new column using existing column in SQL Redshift
I am trying to create a new column in SQL with certain conditions in DBVisualizer by connecting redshift data source. I used the following command to achieve the results but getting syntax error. I would be really grateful for any help. Code: Error: Expected Output: Thanks. Answer As stated in the error message, the IF() function does not exist in
I can’t get the correct output when I use / ORDER BY from my SQL example?
I was playing around SQL sample that I wrote and I’m quite surprised that I couldn’t get the correct output when I use less than, greater than or ORDER BY. for example, select player_name, jersey_number from Players order by ‘jersey_number’ desc; it should give players name and jersey number sort descending order from their jersey number. However, this is what
Transforming a sheet into a table with column names as values in SQL Server
I’ve been given the task of turning the following Excel table into a database table in SQL Server (I have shortened the row count, of course). A car has to go to service every 10.000 kilometers, but for some models there is a fast service that applies only to certain mileages (I don’t know what mileage is called in kilometers