CODE
Whats is the issue with my calculated field here? Thank you in advance!
Wrong type of closing brace for [SEM Cost] after the third THEN
You could simplify by combining the second and third cases since they lead to the same result, and could also remove some unnecessary parentheses
Related
I have a field with the following types of string
X000233756_9981900025_201901_EUR_/
I firstly need to take take the characters to the left of the first _
Secondly I need to take the characters between the first and 2nd _
First _ is CHARINDEX('_',[Line_Item_Text],1) AS Position_1
Second _ is CHARINDEX('_',[Line_Item_Text],CHARINDEX('_',[Line_Item_Text],1)+1) AS Position_2
I was then expecting to be able to do
left([Line_Item_Text],CHARINDEX('_',[Line_Item_Text],1)-1) AS Data_1
Substring([Line_Item_Text],CHARINDEX('_',[Line_Item_Text],1)+1),CHARINDEX('_',[Line_Item_Text],CHARINDEX('_',[Line_Item_Text],1)+1) - CHARINDEX('_',[Line_Item_Text],1)+1)) AS Data_2"
Which should give me
X000233756
9981900025
But getting errors with incorrect number of functions when I start adding and subtracting from CHARINDEX Function.
Any ideas where I am going wrong?
TIA
Geoff
Actually, using the base string functions here is going to be an ugly nightmare. You might find that STRING_SPLIT along with some clever logic might be easier:
SELECT value
FROM STRING_SPLIT('X000233756_9981900025_201901_EUR_', '_')
WHERE LEN(value) > 6 AND NOT value LIKE '[A-Z]%';
This answer assumes that the third and fourth components would always be a 6 digit date and 3 letter currency code, and that the first (but not second) component would always start with some letter.
Demo
I want to count how many rows contains '?' in a column in Numbers(MacOS) .
I use COUNTIF(COLUMN1, "=?").
However, '?' is a wildcard in Numbers, which means any cell contains exact one character will be counted by this formula.
I also tried to use "=\?" but didn't work here.
Example:
COUNTIF(COLUMN1, "=?")=3
But I want just count the number of '?', so the result should be 2
Please help.
Thank you.
I find the solution myself.
Using '~' solve the problem:
COUNTIF(COLUMN1, "=~?")
I am using below code to do calculation
select column1 from tablename where code SIMILAR TO '%(-|_|–)EST[1-2][0-9](-|_)%'
for this column value -CSEST190-KCY18-04-01-L the condition was passed, but in actual I want to ignore this type of data.
The correct value which should pass through the above condition is
-CS-EST19-0-KCY18-04-01-L
-CS_EST19-0-KCY18-04-01-L
Any suggestions, how to avoid this type of confusion?
Easiest way is to go full-regex, instead of using SQL standard SIMILAR TO.
select column1 from tablename where code ~ '[_–-]EST[12][0-9][_-]'
Notice this is does not have to match the full string, and you don't have to add .* on both ends (equivalent of % in LIKE and SIMILAR TO). The reason you got a match on that is, because of the underscore _, which is a single wildcard character.
Also, I switched the order, in the square brackets, so that the dash is the last character. That way it's treated as a character literal, not as a range specifier.
I really need help with coming up with the pattern matching solution...
If the string is <6>[ 84.982642] Killing the process
How can I extract them into three separate strings...
I need one for 6, 84.982642, and Killing the process..
I've tried many things but these brackets and blank spaces are really confusing me and I keep getting the error message
"WARNING: Use of uninitialized value $bracket in pattern match..."
Is there anyway I can somehow write in this way
($num_1, $num_2, $name_process) = split(/[\-,. :;!?()[\]{}]+/);
Not sure how to extract these..
Help Please?
Thank you so much
Assuming the input is in $_
($num_1, $num_2, $name_process) = /^<(\d+)>\[([^\]]+)\]\s+(.*)$/;
This assumes the first token in the angle brackets is always a number. For a little more generality use
($num_1, $num_2, $name_process) = /^<([^>]+)>\[([^\]]+)\]\s+(.*)$/;
Explanation:
<([^>]+)> - a left-angle-bracket followed one or more characters that are not a right angle-bracket, followed by a right-angle bracket.
\[([^\]]+)\] - a left-bracket followed by one or more characters that are not a right bracket, followed by a right bracket
\s+(.*) - one or more spaces, then capture everything starting with the first non-blank after that.
I am reading a manual of VDM++ language. My question is this in some cases he use ";" at the end of statement and somewhere in the same statement he is not using ";".
Below is the example
public Top : () ==> Elem
Top() ==
return (hd stack);
if test
then OpCall()
else return FunCall()
Semi-colons are separators in VDM, rather than terminators as they are in Java and C. So you need the semi-colon where two things are in sequence, such as two definitions or two statements. But you do not need the separator if there is only one thing in the "block".
So your first example may need the trailing semi-colon if another definition follows, but not if "Top" is the last definition in the class/module.
Your second example does not need a semi-colon after OpCall() because it is a single statement in a "then" clause. You might need a semi-colon after the FunCall() if this if/then/else was followed by another statement, but not otherwise.
Having said this, the VDMJ parser is forgiving and will allow spurious semi-colons in some places, even though they are strictly not required.