以2022年亚太杯数学建模C题为例,首先在navicat建数据库然后右键“表”,单击“导入向导”,选择对应的数据格式及字符集进行数据导入
导入之后,我们可以双击刚刚导入的2022_apmcm_c_data表,查看一下数据情况。使用"ctrl"+"q"快捷键来新建SQL查询语言,结构化语言查询页面中会自动生成代码:select * from 2022_apmcm_c_data
由于原数据条数太多,因此我们可以使用mysql中的limit函数简单查看表重所有字段的前100条数据情况。代码如下:
SELECT * FROM `2022_apmcm_c_data` limit 100;
你如果要是计算机专业,不会mysql,那你赶紧找个厂子上班得了;你如果不是计算机专业,没学过mysql我不说什么,不是说轻视,因为这个东西根本不用想,然后还有星号星号博主把mysql说的多么高大上,我今天毫无保留的把mysql这点破玩意都讲给你们。
mysql也好还是oracle数据库也好,它本身最常用最实用的功能就是提供数据存储增删改查的,你tm有的星号星号博主说mysql是机器学习软件,你把读者都当作星号星号是么?它就是个结构化查询语言,别误导读者行么?对于在自己电脑安装mysql的学生,完全没有必要使用建表语句去建表,为什么呢?因为你在导入表之后,双击打开表之后,在表的右侧就会自动生成建表语句,而且这个表在你导入之后就自动建好了。
然后我再多说一嘴,你如果搭建数据库这个环境,完全没有必要在官网下载mysql,因为现在已经有了mysql环境集成程序包,就30MB,无须配置环境而且免费的,你如果安装官网mysql,不仅步骤繁琐,而且占空间太大。我就很好奇这事为啥没一个博主说呢?还是你们不会啊??我带**大学的拿研究生数学建模国奖的时候,你还在那“习莱克特”呢,你还支棱上了,还mysql数学建模,mysql根本做不了数学建模,严格意义上讲是pivot分析。
猪鼻子插葱都在这装象是吧,好,上菜
DESCRIBE 2022_apmcm_c_data;
desc 2022_apmcm_c_data;
select dt,AverageTemperature,Country from 2022_apmcm_c_data;
select sum(AverageTemperature) from 2022_apmcm_c_data;
select distinct City from 2022_apmcm_c_data;
select Country,count(1) from 2022_apmcm_c_data group by Country;
select dt,Country,count(1) from 2022_apmcm_c_data group by dt,Country;
select dt,Country,sum(AverageTemperature) from 2022_apmcm_c_data
group by dt,Country;
select dt,Country,sum(AverageTemperature) from 2022_apmcm_c_data
group by dt,Country ORDER BY dt;
select dt,max(AverageTemperature) from 2022_apmcm_c_data
where YEAR(dt) >=2000 GROUP BY dt ORDER BY dt;
select dt,max(AverageTemperature) from 2022_apmcm_c_data
where from_unixtime(dt,'%Y-%m-%d') GROUP BY dt having
YEAR(dt) >=2000 ORDER BY dt;
select dt,max(AverageTemperature) from 2022_apmcm_c_data
where from_unixtime(CONVERT(dt,date),'%Y%m%d') GROUP BY
dt ORDER BY dt;
select dt,max(AverageTemperature) from 2022_apmcm_c_data
where from_unixtime(cast(dt as date),'%Y%m%d') GROUP BY dt ORDER BY dt;
select dt,max(AverageTemperature) from 2022_apmcm_c_data
where DATE_FORMAT(CONVERT(dt,date),'%Y%m%d') GROUP BY dt ORDER BY dt;
select dt,max(AverageTemperature) from 2022_apmcm_c_data
where DATE_FORMAT(STR_TO_DATE(dt,'%Y-%m-%d'),'%Y%m%d')
GROUP BY dt ORDER BY dt;
select DATE_FORMAT(STR_TO_DATE(dt,'%Y-%m-%d'),'%Y%m%d') from 2022_apmcm_c_data where dt is not null ORDER BY dt;
select dt,max(AverageTemperature) from 2022_apmcm_c_data_copy1
where from_unixtime(CONVERT(dt,date),'%Y%m%d') GROUP BY dt ORDER BY dt;
select max(AverageTemperature) from 2022_apmcm_c_data_copy1
where dt='2013-01-01';
ALTER TABLE 2022_apmcm_c_data_copy1 MODIFY AverageTemperature double;
select max(AverageTemperature) from 2022_apmcm_c_data_copy1
where dt='2013-01-01';
select dt,max(AverageTemperature) from 2022_apmcm_c_data_copy1
where from_unixtime(dt,'%Y-%m-%d') GROUP BY dt having YEAR(dt)
>=2000 ORDER BY dt;
select dt,max(AverageTemperature) from 2022_apmcm_c_data_copy1
where DATE_FORMAT(STR_TO_DATE(dt,'%Y-%m-%d'),'%Y%m%d') >='20000101'
GROUP BY dt ORDER BY dt;
select dt as 日期,Country as 国家,replace(Latitude,'N','') as 纬度,
replace(Longitude,'E','') as 经度 from 2022_apmcm_c_data_copy1 where
from_unixtime(dt,'%Y-%m-%d') GROUP BY dt,Country,Latitude,Longitude
having YEAR(dt) >=2000 ORDER BY dt;
select a.日期,a.国家,replace(a.纬度,'S','') as 纬度,replace(a.经度,'W','') as 经度
from(
select dt as 日期,Country as 国家,replace(Latitude,'N','') as 纬
度,replace(Longitude,'E','') as 经度 from 2022_apmcm_c_data_copy1 where
from_unixtime(dt,'%Y-%m-%d') GROUP BY dt,Country,Latitude,Longitude
having YEAR(dt) >=2000 ORDER BY dt)a;
select b.日期,b.国家,AVG(CONVERT(b.纬度,DECIMAL(10,2))),
AVG(CONVERT(b.经度,DECIMAL(10,2))) from(
select a.日期,a.国家,replace(a.纬度,'S','') as 纬度,
replace(a.经度,'W','') as 经度 from(
select dt as 日期,Country as 国家,replace(Latitude,'N','')
as 纬度,replace(Longitude,'E','') as 经度 from 2022_apmcm_c_data_copy1
where from_unixtime(dt,'%Y-%m-%d') GROUP BY
dt,Country,Latitude,Longitude having YEAR(dt) >=2000
ORDER BY dt)a)b group by b.日期,b.国家;
select CAST(AverageTemperature as decimal(8,2)) from 2022_apmcm_c_data_copy1;
select b.日期,b.国家,AVG(CAST(b.纬度 as decimal(9,2)))
,AVG(CAST(b.经度 as decimal(9,2))) from(
select a.日期,a.国家,replace(a.纬度,'S','')
as 纬度,replace(a.经度,'W','') as 经度 from(
select dt as 日期,Country as 国家,replace(Latitude,'N','')
as 纬度,replace(Longitude,'E','') as 经度 from
2022_apmcm_c_data_copy1 where from_unixtime(dt,'%Y-%m-%d')
GROUP BY dt,Country,Latitude,Longitude having YEAR(dt) >=2000
ORDER BY dt)a)b group by b.日期,b.国家;