tell me pls, that’s real – use the CASE construct, where the expression with IS NULL/IS NOT NULL will be returned in TNEN? I have a procedure in a package that receives an input parameter and it is …
Tag: case
SQL: Using CASE over TABLE that has been GROUPED
I am working with an SQLite Database that has a table CarUse with three fields CarID (VARCHAR(20)), tDate (VARCHAR(20), and Kms (INT). The goal is to create a table that will summarise the Kms over …
WHILE / LOOP inside CASE expression SQL – ORACLE
I am testing a select statement containing a CASE expression and I need to add a WHILE / LOOP inside one of the WHEN conditions. The logic from this statement will eventually be included inside a PL/…
Cannot figure out the issue with this SQL CASE
The issue i am facing is: “SYNTAX_ERROR: line 7:6: All CASE results must be the same type: boolean” I have also joined the table in a previous sub query casting it as a varchar, so there shouldn’t be any issues with this. Anyone have any ideas? For context i am trying to populate a field that would return a blank
sql nested “sum (case when) or” select query
I have a select query where I am trying to sum a value based on multiple criteria, grouped by dimension. The output will be the sum of the time greater than 30, 90, or 365 days based on the category, grouped by category. I can’t crack the syntax for this, I hope you can help! The concept looks something like
Have multiple parameters in a WHEN part of a SQL Update Statement
I need to write a sql update statement without repeating the parameter on the WHEN part of the query, below query works fine however I would like to group the related parameters together, this is how the current query looks like for example I would like to use an IN to group bundle all the STCs belong to 40 together,
Deducting values from 2 case statements from one another
I have two CASE statements and I’m trying to deduct the value of one from another, but I can’t get the code to work. Does anyone have any suggestions where I’m going wrong? The 2 CASE statements are: and When I try to combine these I get errors (missing right parenthesis). The combined code is: as “CALENDAR DAYS”, Answer Forpas
INSERT in CASE expression from subselect PostgreSQL
I am trying to create a query like this WITH insert1 as (), … subselect1 as (SELECT (CASE WHEN %s is NOT NULL THEN (INSERT INTO Duration (duration) VALUES (ROW (%s, %s)) …
How to fix aggregate functions are not allowed in GROUP BY?
I have the following data: Then i do the following query: The result is correct: Then i add two column, name and value: That return: What i expect is: If i add group by on guid_count, cuid_count, and umdid_count: How to overcome this problem? Could you help point me where my mistake is? Thank you. Answer You should use an
Conditionally joining from multiple tables
Does SQL allow some form of conditional “table choosing” within the Join statement? ie. selecting a different table to join based on a predefined variable/condition. The error I get when attempting this method is ORA-00905: missing keyword. Answer No. Neither SQL nor Oracle allow this, unless you use dynamic SQL. Assuming the tables have the same columns, you could write