You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Software Dev <st...@gmail.com> on 2014/05/30 19:16:43 UTC

Help with Query

We have a table with user entered queries, their IP. How could we
write a query that will count and order queries by their count having
a unique IP count > X. For example if we had the same IP enter the
same query Y times we wouldnlt want to include this in the final
result unless there have been X-Y other IP's that searched for that
query.

Is this perhaps better suited fro Pig?

Thanks

Re: Help with Query

Posted by "Petter von Dolwitz (Hem)" <pe...@gmail.com>.
SELECT COUNT(DISTINCT ip) AS count, query_string
FROM myTable
GROUP BY query_string
ORDER BY count DESC;

This should give you one row per asked query. Rows are ordered by nummer of
unique IPs that asked the query. Most popular first.

Br,
Petter
Den 30 maj 2014 19:17 skrev "Software Dev" <st...@gmail.com>:

> We have a table with user entered queries, their IP. How could we
> write a query that will count and order queries by their count having
> a unique IP count > X. For example if we had the same IP enter the
> same query Y times we wouldnlt want to include this in the final
> result unless there have been X-Y other IP's that searched for that
> query.
>
> Is this perhaps better suited fro Pig?
>
> Thanks
>