Skip to content

select practice#140

Open
lionlihuang wants to merge 5 commits into
hcsp:masterfrom
lionlihuang:master
Open

select practice#140
lionlihuang wants to merge 5 commits into
hcsp:masterfrom
lionlihuang:master

Conversation

@lionlihuang

Copy link
Copy Markdown
  • 这个PR解答了当前仓库中的题目(机器人会自动判题并合并当前PR)
  • 这个PR修复了当前仓库中的一些代码缺陷(机器人不会判题,而是由管理员来处理当前PR)

@hcsp-bot

Copy link
Copy Markdown
Contributor

🎉 感谢提交Pull Request!请稍等片刻,我们已经将其提交到CI进行检查,一旦有结果会立即通知您!

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.*;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不应使用 '.*' 形式的导入 - java.sql.* 。

public static List<Order> getLeftJoinOrders(Connection databaseConnection) throws SQLException {
return null;
public static List<GoodsAndGmv> getLeftJoinOrders(Connection databaseConnection) throws SQLException {
String sql = "select GOODS_ID, GOODS.NAME, sum(GOODS_NUM * GOODS_PRICE) as GMV\n" +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'+' 应另起一行。

return null;
public static List<GoodsAndGmv> getLeftJoinOrders(Connection databaseConnection) throws SQLException {
String sql = "select GOODS_ID, GOODS.NAME, sum(GOODS_NUM * GOODS_PRICE) as GMV\n" +
"from `ORDER`\n" +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'+' 应另起一行。

public static List<GoodsAndGmv> getLeftJoinOrders(Connection databaseConnection) throws SQLException {
String sql = "select GOODS_ID, GOODS.NAME, sum(GOODS_NUM * GOODS_PRICE) as GMV\n" +
"from `ORDER`\n" +
" join GOODS ON `ORDER`.GOODS_ID = GOODS.ID\n" +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'+' 应另起一行。

String sql = "select GOODS_ID, GOODS.NAME, sum(GOODS_NUM * GOODS_PRICE) as GMV\n" +
"from `ORDER`\n" +
" join GOODS ON `ORDER`.GOODS_ID = GOODS.ID\n" +
"group by GOODS_ID\n" +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'+' 应另起一行。

@hcsp-bot

Copy link
Copy Markdown
Contributor

你的提交 d1c04d6 ,似乎失败了:Your tests failed on CircleCI

😅 请不要气馁,仔细分析原因,再接再厉!

1 similar comment
@hcsp-bot

Copy link
Copy Markdown
Contributor

你的提交 d1c04d6 ,似乎失败了:Your tests failed on CircleCI

😅 请不要气馁,仔细分析原因,再接再厉!

@hcsp-bot hcsp-bot mentioned this pull request Jun 23, 2020
2 tasks
@hcsp-bot

Copy link
Copy Markdown
Contributor

你的提交 0192096 ,似乎失败了:Your tests failed on CircleCI

😅 请不要气馁,仔细分析原因,再接再厉!

1 similar comment
@hcsp-bot

Copy link
Copy Markdown
Contributor

你的提交 0192096 ,似乎失败了:Your tests failed on CircleCI

😅 请不要气馁,仔细分析原因,再接再厉!

public static List<GoodsAndGmv> getGoodsAndGmv (Connection databaseConnection) throws SQLException {
List<GoodsAndGmv> gmvList = new ArrayList<>();

try (PreparedStatement statement = databaseConnection.prepareStatement("select `order`.goods_id, goods.name, `order`.goods_price * sum(`order`.goods_num) as gmv from `order`\n" +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'+' 应另起一行。

List<GoodsAndGmv> gmvList = new ArrayList<>();

try (PreparedStatement statement = databaseConnection.prepareStatement("select `order`.goods_id, goods.name, `order`.goods_price * sum(`order`.goods_num) as gmv from `order`\n" +
"join goods\n" +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'+' 应另起一行。


try (PreparedStatement statement = databaseConnection.prepareStatement("select `order`.goods_id, goods.name, `order`.goods_price * sum(`order`.goods_num) as gmv from `order`\n" +
"join goods\n" +
"on `order`.goods_id = goods.id\n" +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'+' 应另起一行。

try (PreparedStatement statement = databaseConnection.prepareStatement("select `order`.goods_id, goods.name, `order`.goods_price * sum(`order`.goods_num) as gmv from `order`\n" +
"join goods\n" +
"on `order`.goods_id = goods.id\n" +
"group by `order`.goods_id\n" +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'+' 应另起一行。

* 题目5:
* 查询所有订单信息,哪怕它的用户名、商品名缺失,即LEFT JOIN方式
*/
try (PreparedStatement statement = databaseConnection.prepareStatement("select `order`.id as order_id, user.name as user_name, goods.name as goods_name, `order`.goods_price * sum(`order`.goods_num) as total_price from `order`\n" +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'+' 应另起一行。

"\t\tuser.name AS USER_NAME, \n" +
"\t\tgoods.name AS GOODS_NAME, \n" +
"\t\t`order`.goods_price * sum(`order`.goods_num) AS total_price \n" +
"from `order`\n" +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'+' 应另起一行。

"\t\tgoods.name AS GOODS_NAME, \n" +
"\t\t`order`.goods_price * sum(`order`.goods_num) AS total_price \n" +
"from `order`\n" +
"\tleft join goods\n" +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'+' 应另起一行。

"\t\t`order`.goods_price * sum(`order`.goods_num) AS total_price \n" +
"from `order`\n" +
"\tleft join goods\n" +
"\t\ton `order`.goods_id = goods.id\n" +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'+' 应另起一行。

"from `order`\n" +
"\tleft join goods\n" +
"\t\ton `order`.goods_id = goods.id\n" +
"\tleft join user\n" +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'+' 应另起一行。

"\tleft join goods\n" +
"\t\ton `order`.goods_id = goods.id\n" +
"\tleft join user\n" +
"\t\ton `order`.user_id = user.id\n" +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'+' 应另起一行。

@hcsp-bot

Copy link
Copy Markdown
Contributor

你的提交 8228336 ,似乎失败了:Your tests failed on CircleCI

😅 请不要气馁,仔细分析原因,再接再厉!

1 similar comment
@hcsp-bot

Copy link
Copy Markdown
Contributor

你的提交 8228336 ,似乎失败了:Your tests failed on CircleCI

😅 请不要气馁,仔细分析原因,再接再厉!

"\tleft join user\n" +
"\t\ton `order`.user_id = user.id\n" +
"group by `order`.id")) {
ResultSet resultSet = statement.executeQuery();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你看这个方法是不是和getInnerJoinOrders有大量的代码重复?考虑过抽取一个公用方法出来么?

@hcsp-bot

Copy link
Copy Markdown
Contributor

你的提交 c3168b8 ,似乎失败了:Your tests failed on CircleCI

😅 请不要气馁,仔细分析原因,再接再厉!

1 similar comment
@hcsp-bot

Copy link
Copy Markdown
Contributor

你的提交 c3168b8 ,似乎失败了:Your tests failed on CircleCI

😅 请不要气馁,仔细分析原因,再接再厉!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants