Return-Path: X-Original-To: apmail-hive-user-archive@www.apache.org Delivered-To: apmail-hive-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B175210CA9 for ; Fri, 26 Jul 2013 08:53:52 +0000 (UTC) Received: (qmail 48280 invoked by uid 500); 26 Jul 2013 08:53:50 -0000 Delivered-To: apmail-hive-user-archive@hive.apache.org Received: (qmail 47968 invoked by uid 500); 26 Jul 2013 08:53:49 -0000 Mailing-List: contact user-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hive.apache.org Delivered-To: mailing list user@hive.apache.org Received: (qmail 47953 invoked by uid 99); 26 Jul 2013 08:53:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Jul 2013 08:53:47 +0000 X-ASF-Spam-Status: No, hits=1.7 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of manishd207@gmail.com designates 209.85.214.66 as permitted sender) Received: from [209.85.214.66] (HELO mail-bk0-f66.google.com) (209.85.214.66) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Jul 2013 08:53:41 +0000 Received: by mail-bk0-f66.google.com with SMTP id je9so331101bkc.5 for ; Fri, 26 Jul 2013 01:53:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=mKz0iK+TKnFaUo6j2vKtHR0tra/CQtmknQ9kW7+JHkg=; b=e3PQJJ8NiR+R89abhRaAXfVnTmpl5l5dgETPp7uuaooTmwcNGh6eoOgiCezimmVMWQ xiMdZokxebsV/Atwk6Jgx5MhYlgTB/A5mSRnOKsYk+/1/3OvXMGJxs/g6uMioBckwGqO 6bzqO2DldpXQzeIpi01zWVTrnhZmL3RBvDR1nAxRrIU0Bz8atwtkh9r+2LiqJJ4bnfQ7 dtK0PnoL6Z/RufaV8hYdw7Cje50bNzOwJatE0vBlYSiVQoHd9mKXG/qlLY//ywefCKqI OL7dNY3Z7YVQeSCH2/bKJZFGrmi/yQM09hERP0mSyP2XeYrGJQ1ygQmOMWJxPyGrZnYd coSQ== MIME-Version: 1.0 X-Received: by 10.205.115.17 with SMTP id fc17mr6769326bkc.31.1374828800224; Fri, 26 Jul 2013 01:53:20 -0700 (PDT) Received: by 10.204.187.70 with HTTP; Fri, 26 Jul 2013 01:53:20 -0700 (PDT) Reply-To: dunanimanish@gmail.com In-Reply-To: References: Date: Fri, 26 Jul 2013 14:23:20 +0530 Message-ID: Subject: Re: Need help in joining 2 tables From: manish dunani To: user@hive.apache.org Content-Type: multipart/alternative; boundary=14dae9c0912c43e89f04e266467f X-Virus-Checked: Checked by ClamAV on apache.org --14dae9c0912c43e89f04e266467f Content-Type: text/plain; charset=ISO-8859-1 Hi Rama, Have a look !! Both sql and hiveql looks similar.. try this one.. *How to create view??* * * *Ans:* * * create view v1 as select m.Emp_id, m.Name, m.Dob, a.address1, a.address2, a.address3, a.address4, a.city, a.state, a.zip, a.country from EMP_MASTER m join EMP_ADDRESS a on (m.Emp_id=a.Emp_id) where m.row_create_date=(select MAX(row_create_date) from EMP_MASTER where Emp_id = m.Emp_id) and a.row_create_date = (select MAX(row_create_date) from EMP_ADDRESS where Emp_id = a.Emp_id) On Fri, Jul 26, 2013 at 1:47 PM, Ramasubramanian Narayanan < ramasubramanian.narayanan@gmail.com> wrote: > Hi, > > Need to create a view in HIVE as per the below query (written in Oracle). > Need help to provide the equivalent query in HIVE to create view. > > > *EMP_ADDRESS* > > Emp_Id > Address1 > Address2 > Address3 > Address4 > City > State > Pin > Country > Alternate_Address1 > Alternate_Address2 > Alternate_Address3 > Alternate_Address4 > Alternate_City > Alternate_State > Alternate_Pin > Alternate_Country > row_create_date > > > *EMP_MASTER* > > Emp_Id > Name > DOB > Department > Sex > FathersName > row_create_date > > > *View Query* > > select > MAST.Emp_Id, > MAST.Name, > MAST.DOB, > ADDR.Address1, > ADDR.Address2, > ADDR.Address3, > ADDR.Address4, > ADDR.City, > ADDR.State, > ADDR.Pin, > ADDR.Country > from EMP_MASTER MAST, EMP_ADDRESS ADDR > where > MAST.row_create_date = (select max(row_create_date) from EMP_MASTER where > Emp_Id = MAST.Emp_Id) > and ADDR.row_create_date = (select max(row_create_date) from EMP_ADDRESS > where Emp_Id = ADDR.Emp_Id) > > > regards, > Rams > -- MANISH DUNANI -THANX +91 9426881954,+91 8460656443 manishd207@gmail.com --14dae9c0912c43e89f04e266467f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hi Rama,

Have a look !!

<= /div>
Both sql and hiveql looks similar..
try this one..

How to create view??
Ans:

create view v1 as
select m.Emp_id,
m.Name,
= m.Dob,
a.address1,
a.address2,
a.address3,
a.address4,
a.city,
a.state,
a.zip,
a.country from EMP_MASTER m join EMP_ADDRESS a on (m.Emp_id=3Da.Emp_i= d)
where m.row_create_date=3D(select MAX(row_create_date) from EMP_MASTER where = Emp_id =3D m.Emp_id)
and a.row_create_d= ate =3D (select MAX(row_create_date) from EMP_ADDRESS where Emp_id =3D a.Em= p_id)

=A0


On Fri, Jul 26, 2013 = at 1:47 PM, Ramasubramanian Narayanan <ramasubramanian.n= arayanan@gmail.com> wrote:
Hi,

Need= to create a view in HIVE as per the below query (written in Oracle). Need = help to provide the equivalent query in HIVE to create view.


EMP_ADDRESS

Emp_Id
Address1
Address2
= Address3
Address4
City
State
Pin
Country
Alternate_Address1
Alternate_Address2
Alternate_Address3
Alternate_Address4
Alternate_Ci= ty
Alternate_State
Alternate_Pin
Alternate_Co= untry
row_create_date


EMP_MASTER

Emp_Id
Name
DOB
Department
Sex
FathersName
row_create_date


View Query=

select=A0
MAST.Emp_Id,
MAST.Name,
MAST.DOB,
ADDR.Address1,
ADDR.Address2,
<= div>ADDR.Address3,
ADDR.Address4,
ADDR.City,
ADDR.State,
ADDR.Pin,
ADDR.Country
from EMP_M= ASTER MAST, EMP_ADDRESS ADDR
where
MAST.row_create_date= =3D (select max(row_create_date) from EMP_MASTER where Emp_Id =3D MAST.Emp= _Id)
and ADDR.row_create_date =3D (select max(row_create_date) from EMP_ADD= RESS where Emp_Id =3D ADDR.Emp_Id)


regards,
Rams



--
MANISH DUNAN= I
-THANX
+91 9426881954,+91 8460656443
--14dae9c0912c43e89f04e266467f--