I am currently using MariaDB on arch and whatever is in debian buster reps as mysql in “production”. I’m trying to create following schema: create or replace schema `test` use `test`; …
Oracle SQL ternary operator or function?
Is there a simple Oracle syntax like a ternary operator or function? These work: If there’s a simpler, shorter syntax I would like to know. Answer You can use a CASE expression with LIKE: or DECODE and INSTR: or just simply use LIKE: INSTR: or REGEXP_LIKE: db<>fiddle here
How to create a stored procedure that will update a table
I am trying to create a stored procedure that will update the project status from ‘D’ to ‘C’. As you can see below I do not know what I am doing. Please do not suggest using a trigger as that does not pertain to the question. These are the errors I get when I run this code block: Error…
Why do not display values that I have entered in a database table?
Good evening. I have created a database with ORACLE SQL Developer and am having a small problem. In the RENTING table that I have created something like this: I am trying to enter the following data: cAFM = 10001, vPlateNumber = ‘XKO5434’, OutDate = ’13 / 07/2020 09:30 ‘, InDate = R…
Endless Loop or No Output for Recursive SQL Query
I have the following table, My goal is to create a supervisor view in which there is a 4th column that has the name of the supervisor that matches the S code. My query returns to me either nothing except the column headers or a never ending recursion that loops into the 100,000’s. What I’ve writte…
SQL – How to select date from the past 5 years to include 1st of Jan of the oldest year
I am trying to select data entered for the past 5 years (to start from the 1st of Jan of the first or oldest year). I’ve constructed the query below but it does not begin from the 1st of January of the oldest year. Any help would be appreciated. Answer You seem to be using MySQL. The simplest method is
Tag a row based on aggregate value condition
Here is my dataset, where order is the fix sequence of each product. What I want is another column in here, lets say TagID. TagID is an int value that will based on the aggregate Count column, group it by product if it is greater or equal to 5. So the dataset would look like this: How can I accomplish
Can’t figure out how to get duplicate values out of table in SQL redshift
I am trying to return the foretasted value per item, per warehouse, per day and then add them up for the week. I am pulling from two tables depending on the demand date, but the issue is that both tables have a “creation_date” column with timestamps, so it’s creating multiple raw_forecast en…
How to create a view using data from two tables
I have two tables ITEM id (int), model (varchar), weight (float), fk_type (int) TYPE id (int), name (varchar) And I want to create a view with TypeName (for every type name) –> varchar NumberOfItems (total number of ITEMS for TypeName) —> int NumberOfModels (total number of MODELS for TypeNa…
How to add column inside postgres function without saving it to the db?
I have a postgres DB and I want to create a function that returns a copy of my table with a new column that has a value of 1 if its id is inside the array(idds[]) that the function gets as an input. …