You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@drill.apache.org by Sanjiv Kumar <sa...@gmail.com> on 2016/12/15 18:05:46 UTC
cast not working in adding two columns
Hello
I am using drill 1.9 version in embedded mode and in Window 10.
My question is when i am adding two integer column, its working fine.
e.g:- select P.`costprice` + P.`initialprice` from
testplugin.dbo.testtable P;
NOTE:- both columns costprice and initialprice are integer.
But when i am adding integer column with varchar column, then it working.
e.g:- select P.`costprice` + P.`Name` from testplugin.dbo.testtable P;
or
select P.`costprice` + cast(P.`Name` as int) from
testplugin.dbo.testtable P;
Both are not working.Please suggest some way how to add two different
datatype columns.
--
Thanks & Regards.
Sanjiv Kumar.
Re: cast not working in adding two columns
Posted by Andries Engelbrecht <ae...@maprtech.com>.
What are you trying to achieve?
It seems you are trying to add an integer to a string column numerically.
Can you actually cast the name column to integers?
--Andries
> On Dec 15, 2016, at 10:05 AM, Sanjiv Kumar <sa...@gmail.com> wrote:
>
> Hello
> I am using drill 1.9 version in embedded mode and in Window 10.
> My question is when i am adding two integer column, its working fine.
> e.g:- select P.`costprice` + P.`initialprice` from
> testplugin.dbo.testtable P;
> NOTE:- both columns costprice and initialprice are integer.
>
> But when i am adding integer column with varchar column, then it working.
> e.g:- select P.`costprice` + P.`Name` from testplugin.dbo.testtable P;
> or
> select P.`costprice` + cast(P.`Name` as int) from
> testplugin.dbo.testtable P;
> Both are not working.Please suggest some way how to add two different
> datatype columns.
>
>
>
>
>
>
>
> --
> Thanks & Regards.
> Sanjiv Kumar.