官术网_书友最值得收藏!

WHERE clauses

A WHERE clause is used to filter the result set by using predicate operators and logical operators with the help of the following:

  • List of predicate operators
  • List of logical operators
  • List of functions

Here is an example of using the WHERE clause:

select * from OnlineRetail where Description='WHITE METAL LANTERN' limit 5;

The following is the hive console showing the query execution:

The following query shows us how to use the group by clause:

select Description, count(*) from OnlineRetail group by Description limit 5;

The following is the hive console showing the query execution:

The following query is an example of using the group by clause and specify conditions to filter the results obtained with the help of the having clause:

select Description, count(*) as cnt from OnlineRetail group by Description having cnt> 100 limit 5;

The following is the hive console showing the query execution:

The following query is another example of using the group by clause, filtering the result with the having clause and sorting our result using the order by clause, here using DESC:

select Description, count(*) as cnt from OnlineRetail group by Description having cnt> 100 order by cnt DESC limit 5;

The following is the hive console showing the query execution:

主站蜘蛛池模板: 韶山市| 云和县| 甘南县| 海南省| 高安市| 衡水市| 会同县| 千阳县| 肇庆市| 固镇县| 阿克| 沛县| 新津县| 临海市| 镇原县| 冷水江市| 象州县| 济源市| 政和县| 晋州市| 玉屏| 河北省| 根河市| 威远县| 南靖县| 富民县| 陆川县| 宁河县| 西吉县| 清新县| 乌拉特前旗| 潢川县| 曲松县| 信丰县| 新兴县| 平定县| 兴义市| 利川市| 富顺县| 合山市| 贡嘎县|