-Re: subquery in select
wd 2012-05-28, 09:39
I didn't have run it. I think the sql I write should work in every db....
On Mon, May 28, 2012 at 4:54 PM, shan s <[EMAIL PROTECTED]> wrote:
> That was a typo in the email, but it still errors after the typo is
> Did you try to run it?
> Here is the entire script after creating the file, gt.txt from data
> CREATE EXTERNAL TABLE IF NOT EXISTS gt (id INT, category STRING)
> ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' STORED AS TEXTFILE
> LOCATION '/user/user1/ht/gt';
> LOAD DATA LOCAL INPATH 'gt.txt' OVERWRITE INTO TABLE gt;
> CREATE TABLE IF NOT EXISTS Res (category STRING, count INT, perVal INT)
> ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' STORED AS TEXTFILE;
> INSERT OVERWRITE TABLE Res
> select a.category, a.count, b.totalCount
> (select category, count(*) as count from gt group by category) a,
Maybe you should delete this white line?
> (select count(*) as totalCount from gt) b ;
> On Mon, May 28, 2012 at 1:55 PM, wd <[EMAIL PROTECTED]> wrote:
>> group by category
>> On Mon, May 28, 2012 at 2:20 PM, shan s <[EMAIL PROTECTED]> wrote:
>> > (select category, count(*) as count from gt group by cat) a,