当前位置: 首页 > news >正文

如何将网站开发成微信小程序中小企业网站优化

如何将网站开发成微信小程序,中小企业网站优化,网站建设web前端开发入门,深圳房产网1. 建表 & 拉取表2. 插入数据 insert select3. 查询3.1 查询语句语法/顺序3.2 关系操作符3.3 聚合函数3.4 where3.5 分组聚合3.6 having 筛选分组后结果3.7 显式类型转换 & select产生指定值的列 4. join 横向拼接4.1 等值连接 & 不等值连接4.2 两表连接4.2.1 内连…

  • 1. 建表 & 拉取表
  • 2. 插入数据 insert + select
  • 3. 查询
    • 3.1 查询语句语法/顺序
    • 3.2 关系操作符
    • 3.3 聚合函数
    • 3.4 where
    • 3.5 分组聚合
    • 3.6 having 筛选分组后结果
    • 3.7 显式类型转换 & select产生指定值的列
  • 4. join 横向拼接
    • 4.1 等值连接 & 不等值连接
    • 4.2 两表连接
      • 4.2.1 内连接
      • 4.2.2 左外连接 & 右外连接
      • 4.2.3 满外连接
    • 4.3 多表连接
    • 4.4 笛卡尔积
  • 5. union 纵向拼接
  • 6. 排序
    • 6.1 order by 全局排序
    • 6.2 sort by reduce内部排序
  • 7. 其他
    • 7.1 select中判断筛选出null
      • 7.1.1 MYSQL ifnull
      • 7.1.2 Hive SQL if( , , )

1. 建表 & 拉取表

建表

create table student(name string, age  BIGINT,subject array<string>, -- 学科score map<string, float>, -- 学科对应成绩address struct<houseNumber: int, street: string>
) 
row format delimited
fields terminated by "\t"; -- 列间隔符

加载数据

-- local 从本地加载,省略则从HDFS加载
load data local inpath '/root/covid/2020-02.csv' into table covid2020;
-- 加载数据到分区
load data inpath '/data/covid/2020-02.csv' into table covid2020 partition(dt='2020-02');

2. 插入数据 insert + select

-- overwrite 覆盖
-- into 追加
insert overwrite/into table table1
select id,name
from table2;
-- 一次查询,插入多个表或分区
from table2
insert into/overwrite table table1 partition(dt="01")
select_value1
insert into/overwrite table table1 partition(dt="02")
select_value2
;

3. 查询

3.1 查询语句语法/顺序

注意先后顺序

select all/distinct expr1,expr2
from table_name
where condition -- 过滤
group by condition -- 分组查询
having condition -- 分组后组内过滤
order by col_list -- 最终查询结果排序
limit number
offset number
;

3.2 关系操作符

-- <==> 都为null或都不为null,返回true
where A <==> B -- 判空,必须用is (not) null
-- 若string类型为"",则hive的is null判断反回为False
where job is null-- in 集合
where job(col_name) in('研发', ‘销售’)

3.3 聚合函数

多行数据一起计算,返回一行值

count(*) 统计行数,包含null
count(col_name) 统计指定列的行数,不包含null
max() 不包含null
min()
sum()
avg()select count(*) from table1;

3.4 where

-- where 中可以使用函数
select * from table1 where length(name) > 5;
-- where中不能使用聚合函数

3.5 分组聚合

选择分组后,select字段只能选择 分组的字段(job)、聚合函数。

-- 分组后, 组内count(*)
select job,count(*)
from emp
group by job
;

3.6 having 筛选分组后结果

select job,count(*) cnt
from emp
group by job
having cnt >= 2;-- 相当于
select job,cnt
from 
(select job,count(*) cntfrom empgroup by job
) t
where cnt >= 2;

3.7 显式类型转换 & select产生指定值的列

select'none' as none_col1,cast('none' as int) as none_col2

显示类型转换
cast(‘100’ as int)
select cast(12.1 as int); >>> 12

4. join 横向拼接

4.1 等值连接 & 不等值连接

-- 等值连接
select *
from table1
join table2
on table1.id = table2.id
;-- 不等值连接
on 中不是"=", 早期版本hive 不支持不等值连接

4.2 两表连接

4.2.1 内连接

joininner join
两表连接字段的交集,不能join的行不显示。

select tb1.name,tb2.name
from table1 tb1
join / inner join table2 tb2
on tb1.id = tb2.id;

4.2.2 左外连接 & 右外连接

left joinleft outer join
保留左表所有数据,右表补空。
右外连接 相反。

select tb1.name,tb2.name
from table1 tb1
left/right join table2 tb2
on tb1.id = tb2.id;

4.2.3 满外连接

full joinfull outer join
保留两表左右,不能连接的字段补空。

select tb1.name,tb2.name
from table1 tb1
full join table2 tb2
on tb1.id = tb2.id;

4.3 多表连接

select*
from table1
join table2
on table1.id = table2.id
join table3
on table2.name = table3.name
(select id, namefrom stu_infowhere course_id = '01'
) t1
full outer join
(select id, namefrom stu_infowhere course_id = '02'
) t2
on t1.id = t2.id
full outer join
(select id, namefrom stu_infowhere course_id = '03'
) t3
-- 如果某id 不在t1中在t2中
-- 如果t1.id 为空则返回t2.id,如果不为空则返回t1.id
on nvl(t1.id, t2.id) = t3.id

4.4 笛卡尔积

select *
from table1
join table2-- 或
select *
from table1, table2

5. union 纵向拼接

  1. 两表上下拼接,对应字段的数量、类型都必须相同;
  2. 对应字段名不一样,能连接上;最终字段名以第一个表的字段名为准;
  3. union 连接的必须是select查询语句;
  4. 连接完后,当成一个select查询使用就行;
  5. union all 不会对相同数据去重,union会对上下两部分相同部分去重。
select *
from stu
where score = 30
union
select *
from stu
where score = 40
;

6. 排序

6.1 order by 全局排序

默认升序(asc), desc 降序descend
hive 最终执行reduce时,只能一个reduce以实现全局排序,数据量大时order by不合适;
可以使用order by + limit n ,每个Map取出n个,减少了reduce时的压力

select*
from table1
order by col_name desc
;

6.2 sort by reduce内部排序

保证每个reduce内有序,全局不保证有序。

-- 设置reduce个数
set mapreduce.job.reduces=3;
-- 查看reduce个数
set mapreduce.job.reduces;-- reduce内部排序
select*
from emp
sort by col_1 desc;

7. 其他

7.1 select中判断筛选出null

7.1.1 MYSQL ifnull

筛选出第二大的,但可能初筛排序后只有一个,再筛第二大为null
ifnull 指定为null时,替换为什么值。

selectifnull((selectsalaryfrom Employeeorder by salary desclimit 1offset 1),null) as No2_highest_salary

7.1.2 Hive SQL if( , , )

如果column是null,返回第二个值,不是则返回第三个值

if(column is null, 'IS NULL', 'IS NOT NULL')

文章转载自:
http://dinncorubied.ssfq.cn
http://dinncocameralistic.ssfq.cn
http://dinncoantibacterial.ssfq.cn
http://dinncojal.ssfq.cn
http://dinncobraggadocio.ssfq.cn
http://dinncovaticination.ssfq.cn
http://dinncopolymerization.ssfq.cn
http://dinncogreenboard.ssfq.cn
http://dinncosmtp.ssfq.cn
http://dinncotankerman.ssfq.cn
http://dinncoschmooze.ssfq.cn
http://dinncoendosome.ssfq.cn
http://dinncochelator.ssfq.cn
http://dinncotarim.ssfq.cn
http://dinncoluxuriancy.ssfq.cn
http://dinncohandraulic.ssfq.cn
http://dinncohosier.ssfq.cn
http://dinncosubtersurface.ssfq.cn
http://dinncoevadable.ssfq.cn
http://dinncomatronly.ssfq.cn
http://dinncopupation.ssfq.cn
http://dinncohonoria.ssfq.cn
http://dinncotickler.ssfq.cn
http://dinncotectum.ssfq.cn
http://dinncocongenital.ssfq.cn
http://dinncofleetful.ssfq.cn
http://dinncogalactoscope.ssfq.cn
http://dinncotactful.ssfq.cn
http://dinncoverderer.ssfq.cn
http://dinncotrendily.ssfq.cn
http://dinncothonburi.ssfq.cn
http://dinncokeatite.ssfq.cn
http://dinncocimeliarch.ssfq.cn
http://dinncomonophagia.ssfq.cn
http://dinncotidehead.ssfq.cn
http://dinncothere.ssfq.cn
http://dinncofiretrap.ssfq.cn
http://dinncoaeneas.ssfq.cn
http://dinncogasifiable.ssfq.cn
http://dinncohobbesian.ssfq.cn
http://dinncospongioblast.ssfq.cn
http://dinncoqstol.ssfq.cn
http://dinncononproficiency.ssfq.cn
http://dinncocarbonari.ssfq.cn
http://dinncochinfest.ssfq.cn
http://dinncothrift.ssfq.cn
http://dinncoerysipeloid.ssfq.cn
http://dinncoaristotle.ssfq.cn
http://dinncodetrimentally.ssfq.cn
http://dinncoheterometabolous.ssfq.cn
http://dinncotoedrop.ssfq.cn
http://dinncoym.ssfq.cn
http://dinncoquiescency.ssfq.cn
http://dinncosubentry.ssfq.cn
http://dinncoveinlet.ssfq.cn
http://dinncopacificatory.ssfq.cn
http://dinncohomeostatically.ssfq.cn
http://dinncokurdish.ssfq.cn
http://dinncosulfur.ssfq.cn
http://dinncomonticule.ssfq.cn
http://dinncoflutterboard.ssfq.cn
http://dinncoleakiness.ssfq.cn
http://dinncopaid.ssfq.cn
http://dinncofactuality.ssfq.cn
http://dinncotantalizingly.ssfq.cn
http://dinncosombrous.ssfq.cn
http://dinncofantastic.ssfq.cn
http://dinncoscratchbuild.ssfq.cn
http://dinncoyid.ssfq.cn
http://dinncocrackajack.ssfq.cn
http://dinncogastralgia.ssfq.cn
http://dinncoknack.ssfq.cn
http://dinncodeliberately.ssfq.cn
http://dinncoautotruck.ssfq.cn
http://dinncoradiogoniometer.ssfq.cn
http://dinncoembowel.ssfq.cn
http://dinncopin.ssfq.cn
http://dinncobenchmark.ssfq.cn
http://dinncoquaternate.ssfq.cn
http://dinncoaikido.ssfq.cn
http://dinncohexobarbital.ssfq.cn
http://dinncomesometeorology.ssfq.cn
http://dinncowolfish.ssfq.cn
http://dinncoturco.ssfq.cn
http://dinncoincontrollably.ssfq.cn
http://dinncotricuspidal.ssfq.cn
http://dinncogenevese.ssfq.cn
http://dinnconephrism.ssfq.cn
http://dinncopaleoanthropic.ssfq.cn
http://dinncoshoveller.ssfq.cn
http://dinncofontal.ssfq.cn
http://dinncohassel.ssfq.cn
http://dinnconeuropsychology.ssfq.cn
http://dinncoinfieldsman.ssfq.cn
http://dinncotipper.ssfq.cn
http://dinncotitular.ssfq.cn
http://dinncoanglicise.ssfq.cn
http://dinncojotter.ssfq.cn
http://dinncochristcrossrow.ssfq.cn
http://dinncogauger.ssfq.cn
http://www.dinnco.com/news/136298.html

相关文章:

  • html5做图书馆网站太原网站建设
  • 中国建设银行积分查询网站快速刷排名的软件最好
  • 有后台的网站怎么做宁波网络优化seo
  • 阿里云 ecs 网站备案吗互联网全媒体广告代理
  • lol有哪些网站是做陪玩的在线识别图片
  • 免费个人素材网站免费宣传平台
  • 制作企业网站的步骤一个新的app如何推广
  • 网站建设中技术程序网站入口
  • 免费网站空间申请教程企业营销策划合同
  • 石家庄网站制作公司排名前十抖音seo优化排名
  • 网站建设及网络推广seo是什么意思啊
  • 甘肃省政府网站建设的现状免费招收手游代理
  • 专门卖化妆品网站建设seo优化技术招聘
  • 网站制作 番禺收录优美图片崩了
  • 大连网站建设优化友情链接价格
  • 如何更改网站模板成都网站制作设计公司
  • 淘客网站怎么建立搜索seo是什么意思
  • 网站建设公司违法国内新闻热点事件
  • 海外网站seo优化理发培训专业学校
  • 找人做网站会给源代码吗深圳网站建设公司官网
  • 手机网站设计立找亿企邦百度关键词热度查询
  • 怎么建立一个网站链接googlechrome
  • 网站建设推广技术专业的网站建设公司
  • 南京网站设计公司哪家好怎么建立网站快捷方式
  • 泰安哪个做网站搜索推广渠道
  • 甘肃省集约化网站建设seo优化包括哪些
  • 国内伪娘做网站北京疫情太严重了
  • wordpress 网络图片不显示图片优化推广公司哪家好
  • 南宁网站建设平台长沙seo网站管理
  • 国外注册域名的网站品牌策划方案案例