In my company, each department has their own statuses for purchase orders. I’m trying to load only the pertinent POs for a specific user’s department. I keep getting errors. It seems like it should be correct, though. I initially attempted to use a Case statement, but it appears that SQL can only …
Tag: if-statement
Mysql multiple order, one order by date with condition
I have a simple SQL request which orders the result by the number of sales and then by the number of views. But I would like the new images with a date greater than for example “2022-05-01” to appear just after the ones that have been sold. Is it possible to have multiple order and in one of this …
Print within the SQL Server Select query based on the condition
I have this query from the link here which works fine, only that I am adding include FK constraints ‘ON Delete/ Update cascade’ if delete/update_referential_action is 1. I am unable to achieve the desired result. Any help appreciated. Answer Ms Sql 2016 dose not support if statement in middle of q…
Using if-then or case-when-then to select from dataset
I have a dataset with students in 1st, 2nd and 3rd grades. I want to select the names of all students in 1st and 2nd grades, but only students named John, Jane or Smith from 3rd grade. Here is what I have so far: I’m not sure what I’m getting wrong there but I’d appreciate some help. Thanks …
PL/SQL: IF or CASE statement to check two variables in a single row and return a third variable?
I need PL/SQL code to scan a table (tied to page 5 in Apex), see if a row with two variables (a specific ID and a specific number between 1-3) exists, and return a third variable from that row into an Oracle Apex item (this is a dynamic action on page 10) if it does. I can do this with
Add new column with Boolean in PL/SQL
I’m learning PL/SQL right now and I have a doubt. I have created the following table called tbProducts: And I have inserted some values so the table is like this: Now what I’m looking for is a boolean variable that can be called bUpdate that returns FALSE if today’s date (26-AUG-2021) is gre…
MySQL table update after multi field check
Hi I have two table one like this one: table1 and one like this: table2 I would like to update all the fields on the table2 column “newID” based on this rules: if (table2.ID = table1.ID_actual or table2.ID=table1.ID_old) then table2.newID = table1.newID How can I resolve this problem ? Answer You …
insert value from join with If/Case from two tables, into a third table
So I have the following issue in creating a sql query. A linked server so am using an open query. (edit update: SQL Server) Two tables as per picture below: I need to insert value into a third table, the value to insert to the third table comes from the two tables above which I join via KEY ID. However,
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
MySQL: Updating multiple columns using if else
I need help to set a mySQL update query for my little project like below: In my table, there is a column REFERENCE which contains varchar like where the character before the symbol ‘_’ determines certain values for other columns like stated above. I am still fairly new to mySQL, so appreciates any…