Can I ignore some columns in WHERE condition?
SELECT name FROM people
WHERE name LIKE 'Honza' AND surname LIKE 'Novak'
(I recieve the WHERE condition as parametr unable to edit it)
I think the answer here is no, you cannot. You got the where condition and if you can't edit it, it will be processed as is. If you can add to the end you could add an AND and an OR to override, but that's about it.
Can you do some string replacement on the WHERE? E.g.
replace($WHERE, "surname like 'Novak'", "surname like '%'")
If not, you can maybe hack something with a ON SELECT INSTEAD... rule:
http://www.postgresql.org/docs/9.1/static/sql-createrule.html
Related
I need to be able to use variables in table names - I basically have the same set of tables used for different types of data, so I would like to just have one dashboard and swapping between all types instead of always having to set up multiple identical dashboards.
My query is something like:
select * from table_$variable_name;
Where my list of possible variable is something like cat, dog, bird
I can seem to make this work, if I only put the variable as shown above I get the following error
Error 1146: Table 'table_$variable_name' doesn't exist
If I enclose it in curly brackets, I get this error instead.
Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '{bird}' at line 1
(i.e. with the selected variable actually being visible this time)
I'm not sure if the issue is having underscores in the table names, I tried putting underscores around my variables too to check and I had no luck with that.
Another thing I tried was gradually adding on to the table name, so e.g.
select * from table_$variable;
Still returns an error, but I can see the table name starting to form correctly
Error 1146: Table 'table_bird_' doesn't exist
However, as soon as I add another underscore, the variable is not picked up abymore
```Error 1146: Table 'table_$variable_' doesn't exist``
I'm sure it's something silly I am missing in the syntax of the query - anyone has any suggestions?
Using this https://grafana.com/docs/grafana/latest/variables/templates-and-variables/ for reference
As #arturomp suggests, use
${var:raw}
At least in my case, this was the solution that worked.
I found double square brackets work. e.g.
Rather than
select * from table_$variable_name;
use
select * from table_[[variable_name]];
rule "CHECK SCHEME FOR PBKAS"
when
item : scheme_s1 (itemgroup==0185 || itemgroup==0125)
then
item.setSchemecode("E15-RETGOOMZ_AS");
helper(drools);
end
in above code, itemgroup is a string variable in which value taking from user. and I have already some itemgroup value like 1050,2018,2013 n etc ..so i want to check itemgroup value taking from user with lots of number which already I have as a itemgroup.
how can I do this in when condition or any another way.
please help
It all depends where do you have the values you want to check. If you have them inside a Collection, as a global (i.e. itemgroupsToCheck), then you can write something like this:
global List itemgroupsToCheck;
rule "CHECK SCHEME FOR PBKAS"
when
item : scheme_s1 (itemgroup memberOf itemgroupsToCheck)
then
item.setSchemecode("E15-RETGOOMZ_AS");
helper(drools);
end
If the collection comes from another Fact, then you can write something like this:
rule "CHECK SCHEME FOR PBKAS"
when
YourFact($itemgroupsToCheck: itemgroupsToCheck)
item : scheme_s1 (itemgroup memberOf $itemgroupsToCheck)
then
item.setSchemecode("E15-RETGOOMZ_AS");
helper(drools);
end
Hope it helps,
I want to find a list of people that are missing at least one of these properties: Title, DisplayName, FirstName,LastName, Id, Email.
I have tried the below but get an error
"java.lang.ArrayIndexOutOfBoundsException"
If I only run the first three lines, I am getting results for people that do not have a DisplayName with empty values for that property, however there is no property column for Title.
g.V().hasLabel('people').hasNot('Title')
.or().hasLabel('people').hasNot('DisplayName')
.or().hasLabel('people').hasNot('FirstName')
.or().hasLabel('people').hasNot('LastName')
.or().hasLabel('people').hasNot('Id')
.or().hasLabel('people').hasNot('Email')
Why do you overcomplicate the query? Who not just this:
g.V().hasLabel('people').not(
has('Title').has('DisplayName').
has('FirstName').has('LastName').
has('Id').has('Email'))
However, it's not really clear to me what your expectation is (the statement "however there is no property column for Title" is kinda confusing), but maybe the rewritten query will already help you (if not, then please provide some sample data and the expected result, that always makes it much easier to answer traversal-related questions).
What is the proper way to search a table for every record that starts in a similar way? I have tried:
"THESE. WORDS" IN {example_one.job_title} and {example_two.status} = "A"
But I need all combinations, including "THESE. WORDS*" Adding the asterisk doesn't work, I guess because of how IN works.
To summarize information in the comments,
to limit job_title by the list of values in these. words, you need your field on the left hand side and the values on the right.
you may want {example_one.job_title} LIKE 'keyword*'
If you found this information helpful, you can upvote and/or accept the answer.
so in my query i have select columnx from tblz
it returns 001.255556.84546
I want to be able to split this via '.' and put it into three columns.
column1 = 001
column2 = 255556
column3 = 84576
is this possible?
For info, in 2008 these dont work, you have to do the following:
=Split(Fields!returnedValue.Value, ".").GetValue(0)
Create three calculated fields with the following expressions:
=(Split(Fields!columnx.Value, ".")).GetValue(0)
=(Split(Fields!columnx.Value, ".")).GetValue(1)
=(Split(Fields!columnx.Value, ".")).GetValue(2)
I'm not sure it works or not, maybe give it a try. You might need to use IIF() statement to check values before getting them.
In SSRS you reference the field name, tell it the delimiter to use. Since you are not assigning to a variable, per se, you then need to tell it which part of the split string to use. In your example
=Split(Fields!returnedValue.Value,".")(0)
=Split(Fields!returnedValue.Value,".")(1)
=Split(Fields!returnedValue.Value,".")(2)
You would replace returnedValue with whatever the actual field name is, and place each one of those into your columns 1 - 3, respectively.
This answer was originally posted in the question instead of being posted as an answer:
=(Split(Fields!columnx.Value,".")).GetValue(0)
=(Split(Fields!columnx.Value,".")).GetValue(1)
=(Split(Fields!columnx.Value,".")).GetValue(2)