Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
Hive >> mail # user >> subquery in select


Copy link to this message
-
Re: subquery in select
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
> corrected.
> Did you try to run it?
>
> Here is the entire script after creating the file, gt.txt from data
> below....
>
> 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
> from
> (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,
>
>
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB