How to do "SQL: MINUS Operator" in Servicenow? - servicenow

In ServiceNow, I have 2 queries, A and B.
How could I get C = A - B ?
I know how to do it from sql commands. I want to know how do it in Servicenow ?

You can't. This kind of operation would have to be done in JavaScript in a Script Include.

Related

How to write linq query with multiple conditions in UiPATH

Before asking the question, I don't speak English very well. We apologize for asking again because it is difficult to understand other similar questions.
Question : I want to use linq query with multiple conditions in UiPATH.
Condition 1 : If there is "A" in row, change it to "Alpha".
Condition 2 : If there is "B" in row, change it to "Beta".
...
Condition n(it may be more than 10) : If there is "O" in row, change it to "Omega".
I used the "find and replace" activity, but the higher the number, the slower the processing. As a solution to this, I learned about linq query, but it is difficult to apply and use the basic example.
please help.. thanks..
Linq is suitable for querying or selecting certain rows based on conditions. It is not suitable for updating the data table as such.
You could use to select all rows with A using below statement and use it in a for loop to update the value from A to Alpha
So there is a couple ways you could do this.
Option 1 -
If it's a DataTable that your using then utilise the 'For Each Row' activity.
Then within the for each.
Use the Assign activity
So this would change the value of that row. So you could add your if statement there.
Option 2 -
Use the Invoke Code Activity - set language to C# (or VB - whichever you prefer)
In the Arguments, put your DataTable you are using.
Then go to Edit Code and Input your Linq Statement there.

How to use variable in the query using azure data factory?

I'm trying to use the trigger_start_time variable in the query as the 2nd parameter to a function of lookup activity.
How can I do this ? Can anyone please help me out ?
Please try #concat('select schema.fn_up_watermark(',Parameter_name,',',variable_name, ') from dual') in add dynamic content.
I just make this example with the query you provide me. You could test that not use the parameter and variable to check where missing the right parentheses.
Now, I'm glad to hear the issue is resolved now.
You can do away with the variable and simply write:
select schema.fn_up_watermark('#{item().table_name}','#{pipeline().TriggerTime}') from dual
assuming both parameters are string.
You could still do SQL injection if you can affect the outer lookup that feeds this ForEach block - you could sanitise the table_names on entering this loop possibly.

AzureDatabrick:Error in SQL statement: package.TreeNodeException: execute, tree: Exchange hashpartitioning

currently working with 2 temporary views A & B . while selecting records from individual views it gives results. But when creating 3rd view C with join of A & B it works but when we run any select query on 3rd view C it gives error "Error in SQL statement: package.TreeNodeException: execute, tree: Exchange hashpartitioning"
Please help whats going wrong here.
Possible reason could be, skewed join. i.e., the fields you are joining could have multiple combinations. This can happen mainly when the joining fields also possess null values in both the views then it could result in multiple null joined with multiple nulls.
It can be avoided by adding another possible field. Else join non null values separate and append null values from both sides.
If this does not solve the purpose, do share us some code snippet, we can try replicating and solve the issue.

Hibernate Dynamic Order

Hi i want to sort in HQL
ORDER BY IF g.groupAdminId=:adminid THEN 1 ELSE 0 END ASC
But it doesn't work, i want to have all entities where the user is admin first, how can i archieve this?
I don't believe it is possible to put named parameters outside a where clause.
It is possible to order according to expressions:
from User U
order by case
when U.group.name = 'Admin' then 0
when U.group.name = 'Superuser' then 1
else 2
end asc
More on case in HQL docs :
For your particular problem (having admins before other users) I suggest making two queries and combining the two lists in Java.
There are other ways around this but I do not like any of them:
Multiple mappings
Custom functions

Linq-to-sql Not Contains or Not in?

I'm building a poll widget. I've 2 tables, call them Polls and PollsCompleted. I need to do a linq query to get all the Polls that do not exist for a given user in PollsCompleted.
I have the following sets:
For Polls
Where Active == True
For PollsCompleted
Where UserId == ThisUserId
Where PollId = Polls.Id
Now I need to get all Polls that do not exist in PollsCompleted. I need an example for this using either a single or multiple queries. I've tried to break it down into 2 queries.
Basically, I've 2 IQueryables of type T and T1. I want to take all T's where T.ID does not exist in T1.ParentId.
T.Where(x => ! T1.Select(y => y.ParentID).Contains(x.ID))
In Linq you often work from the bottom up. Here we first get a collection of all the parentIDs in T1 -- the T1.Select(...) part. Then we create a where clause that selects all of the Ts whose IDs are not contained in that set.
Note that the result is a query. To materialize it, use ToList() or similar on the statement above.
Use Except. That will work in this case.
For your reference Enumerable.Except Method

Resources