create database iptest;
use iptest;
//首先创建和文件相对应的表结构
create table data(
`ip` string,
`Date` string,
`day` string,
`traffic` string,
`type` string,
`id` string
)
ROW format delimited fields terminated by ',' STORED AS TEXTFILE;
//接着将文件内容导入该表(预先将文件放入虚拟机的/export/data目录下)
load data local inpath '/export/data/result.csv' into table data;
create table video_article as
(select
type,
id,
count(*) as times
from data
group by type, id
order by times DESC
limit 10);
select * from video_article;
create table city_test as
(select
CONCAT(split(ip,'\\.')[0],'.',split(ip,'\\.')[1]) as city,
ip,
traffic,
type,
id
from data);
select * from city_test limit 10;
create table city as
select
city,
type,
id,
count(*) as cishu
from city_test
group by city,type,id
order by cishu DESC
limit 10;
select * from city;
create table traffic as
select
type,
id,
sum(traffic) as liulian
from city_test
group by type,id
order by liulian DESC
limit 10;
select * from traffic;
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 使用C#创建一个MCP客户端
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 按钮权限的设计及实现