Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Distinct on specific column in Hive

I am running Hive 071 I have a table, with mulitple rows, with the same column value e.g.

 x | y |
---------
 1 | 2 |
 1 | 3 |
 1 | 4 |
 2 | 2 |
 3 | 2 |
 3 | 1 |

I want to have the x column unique, and remove rows that have the same x val e.g.

 x | y |
---------
 1 | 2 |
 2 | 2 |
 3 | 2 |

or

 x | y |
---------
 1 | 4 |
 2 | 2 |
 3 | 1 |

are both good as distinct works only on the whole rs in hive, I couldn't find a way to do it

help please Tx

like image 810
Tomer Avatar asked Sep 13 '11 12:09

Tomer


1 Answers

You can use the distinct keyword:

SELECT DISTINCT x FROM table
like image 139
Aswin Avatar answered Sep 28 '22 07:09

Aswin