You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by usha hive <us...@gmail.com> on 2014/06/24 22:23:09 UTC
Reg: Merging Rows
Hi,
I am trying to merge few rows in to 1 row. I am stuck. Please help me.
Example
id col1 col2 col3 col4
1 44 NULL NULL NULL
1 NULL 37 NULL NULL
1 NULL NULL 88 NULL
1 NULL NULL NULL 99
to
id col1 col2 col3 col4
1 44 37 88 99
Thanks,
Usha
Re: Reg: Merging Rows
Posted by ushahive <us...@gmail.com>.
Thank u so much it helped.
On Tue, Jun 24, 2014 at 2:49 PM, sumit ghosh <su...@yahoo.com> wrote:
> Did you try sum(col1), sum(col2) ... group by id
>
>
> On Tuesday, 24 June 2014 1:23 PM, usha hive <us...@gmail.com> wrote:
>
>
> Hi,
>
> I am trying to merge few rows in to 1 row. I am stuck. Please help me.
>
> Example
> id col1 col2 col3 col4
> 1 44 NULL NULL NULL
> 1 NULL 37 NULL NULL
> 1 NULL NULL 88 NULL
> 1 NULL NULL NULL 99
>
> to
> id col1 col2 col3 col4
> 1 44 37 88 99
>
> Thanks,
> Usha
>
>
>
Re: Reg: Merging Rows
Posted by Andre Araujo <ar...@pythian.com>.
...SUM(COALESCE(col1, 0)), ...
On 25 June 2014 08:01, Krishnan Narayanan <kr...@gmail.com> wrote:
> Try coalesce
>
>
> On Tue, Jun 24, 2014 at 2:49 PM, sumit ghosh <su...@yahoo.com> wrote:
>
>> Did you try sum(col1), sum(col2) ... group by id
>>
>>
>> On Tuesday, 24 June 2014 1:23 PM, usha hive <us...@gmail.com> wrote:
>>
>>
>> Hi,
>>
>> I am trying to merge few rows in to 1 row. I am stuck. Please help me.
>>
>> Example
>> id col1 col2 col3 col4
>> 1 44 NULL NULL NULL
>> 1 NULL 37 NULL NULL
>> 1 NULL NULL 88 NULL
>> 1 NULL NULL NULL 99
>>
>> to
>> id col1 col2 col3 col4
>> 1 44 37 88 99
>>
>> Thanks,
>> Usha
>>
>>
>>
>
--
André Araújo
Big Data Consultant/Solutions Architect
The Pythian Group - Australia - www.pythian.com
Office (calls from within Australia): 1300 366 021 x1270
Office (international): +61 2 8016 7000 x270 *OR* +1 613 565 8696 x1270
Mobile: +61 410 323 559
Fax: +61 2 9805 0544
IM: pythianaraujo @ AIM/MSN/Y! or araujo@pythian.com @ GTalk
“Success is not about standing at the top, it's the steps you leave behind.”
— Iker Pou (rock climber)
--
--
Re: Reg: Merging Rows
Posted by Krishnan Narayanan <kr...@gmail.com>.
Try coalesce
On Tue, Jun 24, 2014 at 2:49 PM, sumit ghosh <su...@yahoo.com> wrote:
> Did you try sum(col1), sum(col2) ... group by id
>
>
> On Tuesday, 24 June 2014 1:23 PM, usha hive <us...@gmail.com> wrote:
>
>
> Hi,
>
> I am trying to merge few rows in to 1 row. I am stuck. Please help me.
>
> Example
> id col1 col2 col3 col4
> 1 44 NULL NULL NULL
> 1 NULL 37 NULL NULL
> 1 NULL NULL 88 NULL
> 1 NULL NULL NULL 99
>
> to
> id col1 col2 col3 col4
> 1 44 37 88 99
>
> Thanks,
> Usha
>
>
>
Re: Reg: Merging Rows
Posted by sumit ghosh <su...@yahoo.com>.
Did you try sum(col1), sum(col2) ... group by id
On Tuesday, 24 June 2014 1:23 PM, usha hive <us...@gmail.com> wrote:
Hi,
I am trying to merge few rows in to 1 row. I am stuck. Please help me.
Example
id col1 col2 col3 col4
1 44 NULL NULL NULL
1 NULL 37 NULL NULL
1 NULL NULL 88 NULL
1 NULL NULL NULL 99
to
id col1 col2 col3 col4
1 44 37 88 99
Thanks,
Usha
回复:Reg: Merging Rows
Posted by snv <sm...@foxmail.com>.
select id, SUM(COALESCE(col1, 0)), SUM(COALESCE(col2, 0)), SUM(COALESCE(col3, 0)), SUM(COALESCE(col4, 0)) from example group by id
------------------ 原始邮件 ------------------
发件人: "usha hive";<us...@gmail.com>;
发送时间: 2014年6月25日(星期三) 凌晨4:23
收件人: "user"<us...@hive.apache.org>;
主题: Reg: Merging Rows
Hi,
I am trying to merge few rows in to 1 row. I am stuck. Please help me.
Example
id col1 col2 col3 col4
1 44 NULL NULL NULL
1 NULL 37 NULL NULL
1 NULL NULL 88 NULL
1 NULL NULL NULL 99
to
id col1 col2 col3 col4
1 44 37 88 99
Thanks,
Usha