# 2024年6月13日Blog

Hadoop实现电商商单分析(2)

上一篇文章链接:
Hadoop实现电商商单分析(1)

二、SQL

show databases ;
use test;

-- 创建日志信息表
describe trackinfo;
drop table if exists trackinfo;
create table trackInfo(
                          id string,
                          url string,
                          sessionId string,
                          ip string,
                          `time` string
)row format delimited fields terminated by ',';

load  data local inpath "/root/SX_data/trackInfo.txt" overwrite into table trackinfo;


-- 创建ip映射信息表
drop table if exists ipInfo;
create table ipInfo(
                       ip string,
                       country string,
                       province string,
                       city string
)row format delimited fields terminated by ',';

load  data local inpath "/root/SX_data/ipInfo.txt" overwrite into table ipInfo;


-- 创建结果信息表
truncate table track_log;
create table track_log(
                          url string,
                          pageId string,
                          ip string,
                          country string,
                          province string,
                          city string
)row format delimited fields terminated by ',';

insert into track_log
select
    url,
    regexp_extract(url,'topicId=(\\d{5})') as pageId,
    t.ip,
    i.country,
    i.province,
    i.city
from trackinfo t
         left join ipinfo i
                   on t.ip = i.ip
;

-- 查询省份浏览量
select

from track_log
group by province;

select
    url,
    regexp_extract(url,'topicId=(\\d{5})') as pageId
from trackinfo t
where id = '20960991758'
;

select regexp_extract("http://www.yihaodian.com/cms/view.do?topicId=18970dgf",'topicId=(\\d{5})')
  • 10
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值