I have list of products which gets renewed on monthly or yearly or both. If the renewal value is ‘M’ then the product is renewed on monthly basis. If the renewal value is ‘Y’ the the product is renewed on yearly basis. So my query is, If I choose method(M/Y) and a particular date(P_date), I want the details of products
Tag: case
Using a subquery in a case statement in a where clause
I want to select different results (from a temp table) based on what a certain parameter is set to in the query. I want to exclude certain inventory SKUs if a particular warehouse is selected. I am getting this error, unfortunately. Msg 512, Level 16, State 1, Line 310 Subquery returned more than 1 value. This is not permitted when
Oracle SQL – implement logic based on CASE expression result
I have following query which returns me of percentage of rows with at least one NULL in any of columns: Query works fine to me and I am getting valid result. But I need to do further action in tablec, based on percentage calculated in my SELECT statement. If percentage of rows with NULL is below 30% I need to
SQL fill empty values in a column based on case when selection
So basically what I want to achieve is that if four columns are empty, one column contains a 1 as value and one column contains 0, then I want to entries in one column meeting the conditions with a default value (0.06077). Meaning: IF COL_A, COL_B, COL_C, COL_D IS NULL and COL_E = 0 AND COL_F = 0 then fill
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
Before/After Difference for a flexible Date (Case)
i have a little problem with a case. I output two date fields (yyyy-mm-dd). the date changes and is flexible. not every entry has the same date fields. I take one date field as an fixed point. If the Date is 4 months before the date, a ‘V’ should be the output. if it is behind it, an ‘N’ should
SQL CASE that matches value or uses LIKE ‘%’
I’m trying to do a wildcard retrieve if a defined variable is blank. But I can’t figure out the correct syntax. Answer It is as simple as this: The expression NULLIF(x, ”) will convert ” to null. Then we take advantage of how null comparison works: If @customerID is not null then first condition will be true only for exact
SQL statement to increment multiple case functions from multiple tables
I’m trying to increment the SQL generated column “Counter” by making 1 case statement. I get the error “Invalid Column” for Counter in my case statement. Any help is appreciated. Answer Shot in the dark. It’s not clear what order you need the rows to be counted or what the relationship between the two tables is. Per comment below it
How to Return Separate Sums of Columns if Initial Value in row is 0 in SQL
I am trying to write a SQL query that will return unique rows of sums of shipped part numbers per customer depending on if the value is negative or positive. For example: If we shipped 20 of part Z to customer A twice, and they returned 6 parts back to us, it would display: After running query, expected results: The
Access alias in CASE statement
I am trying to create a column called DateStartedStatus that utilizes a previously aliased column to compute its value. It should use CurrentStatus to output a value and an error is showing that says “Invalid column name ‘CurrentStatus'”. How can I access that alias in the below case statement? Answer Using subqueries like this Do not worry, subquery will not