我想得到所有卷的总和,但我不知道如何得到加仑/秒与升/秒或毫升/秒的总和。
我使用这个SQL查询:
public void mousePressed(MouseEvent e , int tankid) {
System.out.println("insert which tanks you want to move");
JButton clicked = (JButton)e.getSource();
System.out.println(clicked.getAlignmentX()+"mmmmmmmmmmm");
for(int x = 0; x<board.r; x++)
{
for(int y = 0;y<board.cc;y++)
{
if(clicked == board.squares[x][y])
{
ImageIcon icon = new ImageIcon("C:/Users/win_10/Desktop/tanks/tank1.png");
board.squares[troops[tankid].getPosition().x][troops[tankid].getPosition().y].setIcon(null);
board.squares[x][y].setIcon(icon);
map.mapboard[troops[tankid].getPosition().x][troops[tankid].getPosition().y].setBackground(null);
troops[i].getPosition().x = x;
troops[i].getPosition().x = y;
map.mapboard[troops[tankid].getPosition().x][troops[tankid].getPosition().x].add(new JLabel(name));
SwingUtilities.updateComponentTreeUI(map.getContentPane());
System.out.println(x + " "+ y);
}
}
}
}
这是我的示例数据:
SELECT CONCAT(TRIM(SUM(Raw_Quantity *
CASE WHEN Unit_Name= 'mL/s' THEN 1
WHEN Unit_Name= 'liter/s' THEN 1000
WHEN Unit_Name= 'gallon/s' THEN 3.785
END)) / 1000, ' liter/s')
WHEN TRIM(SUM(Raw_Quantity *
CASE WHEN Unit_Name= 'mL/s' THEN 1
WHEN Unit_Name= 'liter/s' THEN 1000
WHEN Unit_Name= 'gallon/s' THEN 3.785
END)) + 0 >= 1
THEN CONCAT(TRIM(SUM(Raw_Quantity *
CASE WHEN Unit_Name= 'mL/s' THEN 1
WHEN Unit_Name= 'liter/s' THEN 1000
WHEN Unit_Name= 'gallon/s' THEN 3.785
END)) / 1, ' mL/s')
WHEN TRIM(SUM(Raw_Quantity *
CASE WHEN Unit_Name= 'mL/s' THEN 1
WHEN Unit_Name= 'liter/s' THEN 1000
WHEN Unit_Name= 'gallon/s' THEN 3.785
END)) + 0 >= 3.785
THEN CONCAT(TRIM(SUM(Raw_Quantity *
CASE WHEN Unit_Name= 'mL/s' THEN 1
WHEN Unit_Name= 'liter/s' THEN 1000
WHEN Unit_Name= 'gallon/s' THEN 3.785
END)) / 3.785, ' gallon/s')
END) AS 'QUANTITY',
GROUP_CONCAT(
CASE WHEN Unit_Name = 'liter/s' AND Raw_Expiration_Date.Raw_Quantity < 1 THEN 'mL/s'
WHEN Unit_Name = 'gallon/s' AND Raw_Expiration_Date.Raw_Quantity < 1 THEN 'liter/s'
WHEN Unit_Name = 'liter/s' AND Raw_Expiration_Date.Raw_Quantity > 3.785 THEN 'gallon/s'
ELSE Unit_Name
END) SEPARATOR '') AS 'Raw_Expiration_Date'
FROM Raw_Expiration_Date
INNER JOIN Raw_Material_Table ON Raw_Expiration_Date.Raw_ID = Raw_Material_Table.Raw_ID
INNER JOIN unit_table ON unit_table.Unit_ID = raw_expiration_date.Unit_ID
GROUP BY Raw_Material_Table.Raw_ID
ORDER BY Raw_Name ASC;
但是,结果不正确:
9.5786523升/秒
我认为我的错误在于如何计算加仑/秒。我在这些计算中做错了什么?
答案 0 :(得分:0)
如果确实有3.785升加仑,那么问题是你的加仑乘数是3.785,但应该是3785.0