一般来说,select查询的resultset中的行从0开始。使用offset子句,我们可以决定从哪里考虑输出。 例如,如果我们选择偏移为0,结果将像往常一样,如果我们选择偏移为5,结果从第五行开始。
以下是Impala中的biasclause的语法。
select data from table_name Group BY col_name;
假设我们在数据库my_db中有一个名为customers的表,其内容如下 -
[quickstart.cloudera:21000] > select * from customers; Query: select * from customers +----+----------+-----+-----------+--------+ | id | name | age | address | salary | +----+----------+-----+-----------+--------+ | 3 | kaushik | 23 | Kota | 30000 | | 6 | Komal | 22 | MP | 32000 | | 1 | Ramesh | 32 | Ahmedabad | 20000 | | 5 | Hardik | 27 | Bhopal | 40000 | | 2 | Khilan | 25 | Delhi | 15000 | | 8 | ram | 22 | vizag | 31000 | | 9 | robert | 23 | banglore | 28000 | | 7 | ram | 25 | chennai | 23000 | | 4 | Chaitali | 25 | Mumbai | 35000 | +----+----------+-----+-----------+--------+ Fetched 9 row(s) in 0.51s
您可以按其id的升序排列表中的记录,并使用limit和order by子句将记录数限制为4,如下所示。
Query: select * from customers order by id limit 4 +----+----------+-----+-----------+--------+ | id | name | age | address | salary | +----+----------+-----+-----------+--------+ | 1 | Ramesh | 32 | Ahmedabad | 20000 | | 2 | Khilan | 25 | Delhi | 15000 | | 3 | kaushik | 23 | Kota | 30000 | | 4 | Chaitali | 25 | Mumbai | 35000 | +----+----------+-----+-----------+--------+ Fetched 4 row(s) in 0.64s
以下是偏移子句的示例。 这里,我们按照id的顺序在customers表中获取记录,并从第0行开始打印前四行。
[quickstart.cloudera:21000] > select * from customers order by id limit 4 offset 0;
执行时,上述查询给出以下结果。
Query: select * from customers order by id limit 4 offset 0 +----+----------+-----+-----------+--------+ | id | name | age | address | salary | +----+----------+-----+-----------+--------+ | 1 | Ramesh | 32 | Ahmedabad | 20000 | | 2 | Khilan | 25 | Delhi | 15000 | | 3 | kaushik | 23 | Kota | 30000 | | 4 | Chaitali | 25 | Mumbai | 35000 | +----+----------+-----+-----------+--------+ Fetched 4 row(s) in 0.62s
以相同的方式,您可以从具有偏移5的行开始从客户表获取四个记录,如下所示。
[quickstart.cloudera:21000] > select * from customers order by id limit 4 offset 5; Query: select * from customers order by id limit 4 offset 5 +----+--------+-----+----------+--------+ | id | name | age | address | salary | +----+--------+-----+----------+--------+ | 6 | Komal | 22 | MP | 32000 | | 7 | ram | 25 | chennai | 23000 | | 8 | ram | 22 | vizag | 31000 | | 9 | robert | 23 | banglore | 28000 | +----+--------+-----+----------+--------+ Fetched 4 row(s) in 0.52s
场景介绍TTS、Wireless、Network、Input、Sound、Display、Date、Call、General 九类定义了表征终端设备状态的相关字段,如屏幕...
风暴最初是由Nathan马兹和团队BackType创建。 BackType是一个社交分析公司。后来,风暴被收购和被Twitter开源。在很短的时间,阿...
AttrSetpublic interface AttrSet定义如何存储、读取和使用与 Component 控件相关的属性,以及其他需要使用属性集的类。字段摘要...
Component.DrawTaskpublic static interface Component.DrawTask实现绘图任务。您可以使用 Component.addDrawTask(ohos.agp.comp...
Component.LayoutRefreshedListenerpublic static interface Component.LayoutRefreshedListener提供在再次布局组件时调用的回调...
Component.SpeechEventListenerpublic static interface Component.SpeechEventListener提供当语音事件绑定到组件时要调用的回调...
Picker.Formatterpublic static interface Picker.Formatter格式化 Picker 的值并将其转换为字符串。您必须实现 format(int) 接...
SlideDrawer.SlideDisablepublic static interface SlideDrawer.SlideDisable允许实时禁用幻灯片。方法总结修饰符和类型方法描述...
Buttonjava.lang.Object |---ohos.agp.components.Component |---|---ohos.agp.components.Text |---|---|---ohos.agp.component...