具有多个限制子句

时间:2016-05-12 08:50:50

标签: sql hive limit apache-spark-sql

我是Hive的新手并且引发了sql技术。我曾在spark sql中尝试过limit子句。但它只支持从零开始到特定限制的特定限制。但我想从特定的起始点检索行到特定的终点。可以请任何人建议实现此目的的方法。

Query1 :: SELECT * FROM `Emp` LIMIT 10;  - this query supports in both sql and spark sql

Query2 :: SELECT * FROM `Emp` LIMIT 10,20;  - to retrive rows from 10 to 20 supports in sql, but not in spark sql. 

2 个答案:

答案 0 :(得分:0)

尝试修改LEFT JOIN:

var res = aFlightList
     .GroupBy(item => 
              // State that you want to group by date
              item.FlightDate, 
              // Will be called for each pair, you don't use the key as it's already part of the original object you will return, here for each group you'll only return a single item, the lowest priced one and will end up with an IEnumerable containing the cheapest one of each group
              (key, pairs) => pairs
                    .OrderBy(p => p.PriceView)
                    .First());

答案 1 :(得分:0)

您可以在HQL中使用ROW_NUMBER

SELECT *,ROW_NUMBER over (Order by id)  as rowid FROM `Emp`
where rowid > 10 and rowid <=20;