I am fairly new to Hive so please excuse me if I use any wrong terms. I basically want to convert/cast the output of
SELECT to_date(EXPOSURE.ETL_START_DATE) as EXPOSURE_Date_Key
into a string and also
coalesce(EXPOSURE_OPEN.open,0) as open,coalesce(EXPOSURE_CLOSED.closed,0) as closed
into a string too.
Please help. I have tried really hard for 2 days on this but couldn't solve it. Thanks in advance!
you can use the cast statement like this
SELECT cast(to_date(EXPOSURE.ETL_START_DATE) as string) as EXPOSURE_Date_Key
SELECT cast(coalesce(EXPOSURE_OPEN.open,0) as open,coalesce(EXPOSURE_CLOSED.closed,0) as string) as closed
Related
I have a text field called Emp_number in the format of A1234567. I want to get the right 7 characters and then cast those 7 characters to Int.
However I sometimes get "dirty" data eg F1234G99 then I don't want to cast it.
How can I write my where clause to do this in SQL? I'm a beginner so please be very specific.
Thanks.
This question already has an answer here:
I get Formula parse error with all formulas
(1 answer)
Closed 4 months ago.
I am trying to use IF statement in a Google Sheet, but whatever I am typing in the IF I am always getting a formula parse error. Do I have to activate something, or am I missing something ?
A1 & B1 have the same type (integer)
I have no idea why.
Thanks in advance
instead of , use ; - this should solve your issue asap
I have recently started a new job and I am using tools which I am not very familiar with. so i was wondering if the StackOverFlow family could help me out.
I have this concatenation in SAS, but I am not able to sort it out on TERADATA
t1.COD_CZ||PUT(INPUT(t1.CODTC,5.),z4.)||PUT(t1.PROGOPE,z8.) as CODIGO_MCT
I have written something like this, but then the length of the string is not harmonized with the the result in sas.
t1.COD_CZ|| cast(cast(t1.CODTC as int) as char(4))|| cast(t1.PROGOPE as char(8)) as CODIGO_MCT
Can you gently enlight me? thanks in advance
You must apply a FORMAT to get leading zeroes (concatenating trims trailing spaces):
t1.COD_CZ||Cast(t1.CODTC AS FORMAT '9(4)')||Cast(t1.PROGOPE AS FORMAT '9(8)')
The result has a fixed length, but it's still a VarChar(17). If you need fixed length, e.g. for export:
CAST(t1.COD_CZ||Cast(t1.CODTC AS FORMAT '9(4)')||Cast(t1.PROGOPE AS FORMAT '9(8)') AS CHAR(17))
I want to get a clean number from a string like "123.45". On using of =TO_PURE_TEXT(C10) it doesn't work for me,
against an example from the documentation. An absolute referencing doesn't help.
But, if i use no cell referencing, but direct input, like =TO_PURE_TEXT("123.45") the input is correct, as expected without quotes.
Is it a kind of bug, or do i really do something wrong? How can i get this work with the cell referencing?
all you need is:
=SUBSTITUTE(C10, """", )*1
or:
=REGEXREPLACE(C10, """", )*1
I can't speak to whether it's a bug. Does seem odd, but this should work for now:
=1*SUBSTITUTE(C10,CHAR(34),"")
I want to compare a string in perl below is detail description
original string
../db/proj/upload/1/22352/eng_wall_paper.jpg
I need to extract the file name eng_wall_paper.jpg from the string
and compare it with variable and append the new variable to the string.
new required string
../db/proj/upload/1/22352/new string.jpg
how can it be done, thanks in advance .
Now as you can see in the comment in your question that you really need to be specific about where you are actually stuck in to ask a question in SO. However, after looking at your other questions in SO it looks like you are completely new in programming world and need serious helping hand. Hence I think it would be helpful for you to get some useful reference to solve your problem.
If I breakdown your main problem statement I can see three parts
1. Need to extract the file name,
Most recommended way to do it is using File::Basename. However, its possible to use regex too. You need to learn how to write regex and how to capture a group. This link should be really helpful.
2. Compare it with variable,
Whichever method you use from above you should get the filename in a variable or in $1. Just compare that whatever you want to compare with. Make sure to use eq instead of ==. Find more details here.
3. Append the new variable to the string,
By now you should have the old filename in a variable, say $oldname, from first step and the new filename in another variable, say $newfilename. This question is already answered several times in SO, like this one. Hope that helps.
The actual solution is merely a 3 or 4 lines of code which I want you to figure out. Good luck.