此文章是vip文章,如何查看?  

1,点击链接获取密钥 http://nicethemes.cn/product/view29882.html

2,在下方输入文章查看密钥即可立即查看当前vip文章


sql与pig比较

  • 时间:
  • 浏览:
  • 来源:互联网
                                                                     sql与pig比较
1.select      select column_name from table_name;            foreach alians generate column_name;

2.select *    select * from table_name;                      foreach alias generate *;

3.distinct    select distinct column_name from table_name;   distinct(foreach alians generate column_name,cloumn_name);

4.where       select colum_name ,column_name from table_name where column_name opertor value    foreach(filter alias by column_name operator value) generate colum_name,column_name;

5.and/or     ...where(column_name operator value1 and column_name operator value2) or column_name operator value3  filter alias  by (column_name operator value1 and column_name operator value2) or column_name operator value3;

6 order by   ...order by colum_name asc|desc,column_name asc|desc;      order alias by colum_name asc|desc,column_name asc|desc;

7.top/limit   select top number colum_name from table_name order by column_name asc|desc       foreach (group alias by column_name) generate limit alias number

8 group by  select function(column_name) from table group by column_name     foreach(group alias by column_name) generate function(alias.column_name)

9 like   where column_name like pattern;    filter alias by regeex_extract(column_name,pattern,1) is not null;

10. in   where column_name in(value1,value2,...);   filter alias by column_name in(value1,value2,...)

11.join     select column_name(s) from table1 join table2 on table1.column_name=table2.column_name;    foreach (join alias1 by column_name,alias2 by column_name) generate column_name(s);


sql function
1.left/right/full outer join   select column_name(s) from table1 left|rigth|full outer join table2 on table1.cloumn_name=table2.cloumn_name;           foreach (join alias1 by column_name left|rigth|full,alias2 by column_name) generate column_name(s)

2.union all select column_name(s) from table1 union all select column_name(s) from table2;   union alias1,alias2

3.avg select avg(column_name) from table_name;    foreach(group alias all) generate avg(alias.column_name);

4.count select count(cloumn_name) from table_name;    foreach(group alias all) generate avg(alias);

5.count distinct  select count(distinct column_name) from table_name;   foreach alias{unique_column=distinct column_name;generate count(unique_column)};

6.max  select max(column_name) from table_name;   foreach(group alias all) generate max(alias.column_name)

7.min   select min(column_name) from table_name;   foreach(group alias all) generate min(alias.column_name)

8.sum   select sum(column_name) from table_name;   foreach(group alias all) generate sum(alias.column_name)

9.having ...having aggregate_function(column_name) operate value;    filter alias by aggregate_function(column_name) operate value

10.ucase/upper select ucase(column_name) from table_name;   foreach alias  generate upper(column_name)

11.lcase/lower select lcase(column_name) from table_name;   foreach alias  generate lower(column_name)  

12.substring select substring(column_name,start,length) as some_name from table_name;  foreach alias  generate substring(column_name,start,length) as some_name

13.select len(column_name) from table_name;    foreach alias  generate size(cloumn_name);

14.round select round(column_name,0) from table ;       foreach alias  generate round(cloumn_name);

本文链接http://element-ui.cn/news/show-577094.aspx