# Write your MySQL query statement belowSELECT s1.product_id,s1.first_year,s2.quantity,s2.price
FROM(SELECT product_id,Min(year) first_year
FROM Sales
GROUPBY product_id
)s1
INNERJOIN Sales s2
ON s1.product_id=s2.product_id AND s1.first_year=s2.year
1.3 运行截图
2 小众书籍
2.1 题目内容
2.1.1 基本题目信息
2.1.2 示例输入输出
2.2 示例sql语句
# 要注意筛选掉今日之后的日期# 分组之后是不可用IFNULL函数SELECT b.book_id,b.name
FROM(SELECT*FROM Books
WHERE DATEDIFF('2019-06-23',available_from)>=30)b
LEFTJOIN(SELECT*FROM Orders
WHERE dispatch_date between date_sub('2019-06-23',interval1year)and dispatch_date
)o
ON b.book_id=o.book_id
GROUPBY b.book_id
HAVING IFNULL(sum(o.quantity),0)<10
2.3 运行截图
3 每日新用户统计
3.1 题目内容
3.1.1 基本题目信息
3.1.2 示例输入输出
3.2 示例sql语句
# 找到符合条件的最少时间的的记录# 求时间查值用DATEDIFF函数 已知日期-日期字段# 具体天数最好用SDATEDIFF函数SELECT t1.mDate login_date,count(user_id) user_count
FROM(SELECT user_id,min(activity_date) mDate
FROM Traffic
WHERE activity='login'GROUPBY user_id
)t1
WHERE DATEDIFF('2019-06-30',t1.mDate)<=90GROUPBY t1.mDate
ORDERBY user_count asc,t1.mDate asc
1. 使用传统JDBC方法与Model 1模型通过JSP页面访问数据库。
【步骤1】在MySQL数据库test中创建books表,其结构如下:
创建数据库MySQL代码与插入数据代码
drop database if exists web_test;
create database web_test character set utf8mb4;use web_…
windows服务器中,定时备份数据库(全量备份)。 创建一个bat文件,内容为: set dd%date:~8,2% set mm%date:~5,2% set yy%date:~0,4% set folder%yy%-%mm%-%dd% md D:\db_backup\%folder% exp db_name/db_pwd127.0.0.1/or…