Subsonic Complex SQL conditional statements - Condition1 And (( Condition2 And Condition3) OR (Condition4 And Condition5)) - subsonic

How do I build a query in Subsonic that of this format:
Condition1 And (( Condition2 And Condition3) OR (Condition4 And Condition5))
The originial SQL Query is:
SELECT *
FROM Events
WHERE Deleted=false
AND ((DateModified IS NOT NULL AND DateModified BETWEEN #date1 AND #date2) OR (DateModified IS NULL AND DateCreated BETWEEN #date1 AND #date2))
I've tried arious approaches, using AndExpreession(), OrExpression(), OpenExpression(), CloseExpression() but I cant seem to get the desired result.
Thanks in advance for your answer.

For that particular query, why not get rid of all the parenthesis and simply let the operator precedence take over:
Condition1 And Condition2 And Condition3 OR Condition1 And Condition4 And Condition5

Related

SQL query to Excel formula conversion

How to convert this SQL query to an Excel formula?
CASE
WHEN UPPER(V_out) = 'GOOGLE' OR (UPPER(V_out) = 'APPLE' AND dis > 800)
THEN 2
ELSE
CASE
WHEN UPPER(V_out) IN ('APPLE', 'MOZILLA', 'SAMSUNG') OR UPPER(V_out) IS NULL
THEN 0
ELSE -2
END
END
So far I have tried this:
=IF(AND(CU2>800;OR(UPPER(LS2)="GOOGLE";UPPER(LS2)="APPLE"));2;IF(OR(MATCH(UPPER(LS2);{"APPLE";"MOZILLA";"SAMSUNG"};0);UPPER(LS2)=0);0)-2)
And it doesn't seem to work.
Any ideas where I made a mistake?
Thanks!
The MATCH needs a ISNUMBER(...) wrapper:
ISNUMBER(MATCH(UPPER(LS2);{"APPLE";"MOZILLA";"SAMSUNG"};0))
That way it returns a TRUE/FALSE and not a number or error.
and UPPER(LS2)=0 just needs to be LS2=""
and AND(CU2>800;OR(UPPER(LS2)="GOOGLE";UPPER(LS2)="APPLE")) does not quite match the case statement:
OR(UPPER(LS2)="GOOGLE";AND(UPPER(LS2)="APPLE";CU2>800))
is more like the case statement.
The -2 is in the wrong place.
=IF(OR(UPPER(LS2)="GOOGLE";AND(UPPER(LS2)="APPLE";CU2>800));2;IF(OR(ISNUMBER(MATCH(UPPER(LS2);{"APPLE";"MOZILLA";"SAMSUNG"};0));LS2="");0;-2))

how to implement an 'or' filter in ReferenceArrayInput

please i want to implement an 'or' filter in ReferenceArrayInput
ex. parentId = 1 or null
anyone can help how can i do it
<ReferenceArrayInput
source="categoriesIds"
reference="categories"
label="Categories"
filter=???
>

Trying to write a simple computed column expression (IF Statement)

I have a column in my table called "BanquetPrize" and another column called "PrizeWinner." If the "BanquetPrize" field is NOT NULL, I'd like the "PrizeWinner" field to auto-fill with "YES," and if it IS NULL, it should be "NO." (Persisted)
I'm really new to SQL and coming from DBF tables where the expression would have been:
IF(IsNotBlank(BanquetPrize), "YES", "NO")
But I can't figure out how to write it in SQL. What I've tried:
(IIF [BanquetPrize]isnotnull then 'YES' else 'NO' end)
-- and also --
(case when [BanquetPrize]isnotnull then 'YES' else 'NO' end)
Obviously the syntax was wrong with both of these, so I was hoping someone could educate me on the correct way to write it?
In SQL You want to use IS NULL as shown in the following code
CASE [BanquetPrize]
WHEN IS NULL THEN 'NO'
ELSE 'YES'
END
You can also do something like the following to give the return column a name, in this case I am giving it a name same as column which is BanquetPrize
CASE [BanquetPrize]
WHEN IS NULL THEN 'NO'
ELSE 'YES'
END AS 'BanquetPrize'
Additional Example when using CASE in ORDER BY Clause
SELECT CustomerName, City, Country
FROM Customers
ORDER BY
(CASE
WHEN City IS NULL THEN Country
ELSE City
END);
Read more about SQL CASE statement and using IS NULL here https://www.w3schools.com/sql/sql_case.asp
You can use CASE or IIF
CASE
SELECT BanquetPrize, CASE WHEN BanquetPrize IS NOT NULL THEN 'YES' ELSE 'NO' END as PrizeWinner
FROM t1;
IIF
SELECT BanquetPrize, IIF(BanquetPrize iS NOT NULL,'YES','NO') as PrizeWinner
FROM t1;
Demo

Combining two separate case statements in NetSuite Case Statements

I currently have two separate saved search columns for these two statements, and I'm hoping to combine them and list the data in just one column. I've tried OR AND, but the results then error out.
First Statement
Case when {item.custitem54} is null then {quantity} else null end
Second Statement
Case when {item.custitem54} = 'Yes' and {shipdate} between to_date('05/25/2020', 'MM/DD/YYYY') and to_date('12/25/2020', 'MM/DD/YYYY') then {quantity} else null end
You can have multiple WHEN in a case statement. The first matched WHEN determines the result unless it gets to the ELSE.
Case when {item.custitem54} = 'Yes'
and {shipdate} between date '2020-05-25' and date '2020-12-25' then {quantity}
when {item.custitem54} is null then {quantity}
else null
end

Hide a webpart using a query string parameter?

I have two web-parts on a same page template and I would like to hide one one of them using a value coming through my query string parameter.
How can I hide a web-part using a query string parameter in Kentico 8 and above?
I am assuming you know how to reach visibility section of the webpart.
Click on the little arrow icon highlighted.
Let's assume the querystring parameter name is cat and you want to show it if it's value is "Visible"
So you can do it like this
{% if( QueryString.GetValue("cat") = "Visible" {true}else{false} #%}
You can also do it in a reverse way like this
**{% if( QueryString.GetValue("cat") != "Visible" {false}else{true} #%}**
Edit:-
You can use this to check multiple values for a single clause like this
if( QueryString.GetValue("cat") != "Visible" && QueryString.GetValue("cat") != "")
You can also use this to combine multiple queries like I did in my case.
if( QueryString.GetValue("cat") != "" || QueryString.GetValue("Author") != "" || QueryString.GetValue("tagname") != "") {true}else{false} #%}
Of course, you can interchangeably use "||" and "&" by tweaking your logic.
I hope this is enough to handle to all your cases. Let me know if it works.

Resources