Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 如何使用group by获得一行中总行值的总和? 选择customerid, (rentaldropoffdate-rentalpickupdate)以天为单位, 总数( 租金保险额外费用 +(类别DailyRentalRate*(rentaldropoffdate-rentalpickupdate)) )应付总额 从租金, 车辆分类, 租赁保险选择权, 车辆 其中rental.vehicleid=vehicle.vehicleid 和rental.rentalinsuranceoptionid=rentalinsuranceoption.rentalinsuranceoptionid 和vehicle.VEHICLERENTALCATEGORYID=VEHICLERENTALCATEGORYID 分组 客户ID, (rentaldropoffdate-rentalpickupdate) 订购人 应付账款总额;_Sql_Oracle_Oracle11g - Fatal编程技术网

Sql 如何使用group by获得一行中总行值的总和? 选择customerid, (rentaldropoffdate-rentalpickupdate)以天为单位, 总数( 租金保险额外费用 +(类别DailyRentalRate*(rentaldropoffdate-rentalpickupdate)) )应付总额 从租金, 车辆分类, 租赁保险选择权, 车辆 其中rental.vehicleid=vehicle.vehicleid 和rental.rentalinsuranceoptionid=rentalinsuranceoption.rentalinsuranceoptionid 和vehicle.VEHICLERENTALCATEGORYID=VEHICLERENTALCATEGORYID 分组 客户ID, (rentaldropoffdate-rentalpickupdate) 订购人 应付账款总额;

Sql 如何使用group by获得一行中总行值的总和? 选择customerid, (rentaldropoffdate-rentalpickupdate)以天为单位, 总数( 租金保险额外费用 +(类别DailyRentalRate*(rentaldropoffdate-rentalpickupdate)) )应付总额 从租金, 车辆分类, 租赁保险选择权, 车辆 其中rental.vehicleid=vehicle.vehicleid 和rental.rentalinsuranceoptionid=rentalinsuranceoption.rentalinsuranceoptionid 和vehicle.VEHICLERENTALCATEGORYID=VEHICLERENTALCATEGORYID 分组 客户ID, (rentaldropoffdate-rentalpickupdate) 订购人 应付账款总额;,sql,oracle,oracle11g,Sql,Oracle,Oracle11g,那么,如何将Customerid 1的到期总金额计算成一行,而不是两个单独的值呢?将rentaldropoffdate-rentalpickupdate值求和,而不是在GROUP BY中使用它: 选择customerid, 总和(rentaldropoffdate-rentalpickupdate)为天, 总数( 租金保险额外费用 +(类别DailyRentalRate*(rentaldropoffdate-rentalpickupdate)) )应付总额 来自租车公司 内连接车辆v 打开(右v


那么,如何将Customerid 1的到期总金额计算成一行,而不是两个单独的值呢?

rentaldropoffdate-rentalpickupdate
值求和,而不是在
GROUP BY
中使用它:

选择customerid,
总和(rentaldropoffdate-rentalpickupdate)为天,
总数(
租金保险额外费用
+(类别DailyRentalRate*(rentaldropoffdate-rentalpickupdate))
)应付总额
来自租车公司
内连接车辆v
打开(右vehicleid=v vehicleid)
内部连接rentalinsuranceoption rio
ON(r.rentalinsuranceoptionid=rio.rentalinsuranceoptionid)
内部连接车辆内部分类vrc
ON(v.VEHICLERENTALCATEGORYID=vrc.VEHICLERENTALCATEGORYID)
分组
客户ID
订购人
应付账款总额;

对天数进行求和,然后按从组中删除天数

选择customerid,
总和(rentaldropoffdate-rentalpickupdate)为天,
总数(
租金保险额外费用
+(类别DailyRentalRate*(rentaldropoffdate-rentalpickupdate))
)应付总额
从租金,
车辆分类,
租赁保险选择权,
车辆
其中rental.vehicleid=vehicle.vehicleid
和rental.rentalinsuranceoptionid=rentalinsuranceoption.rentalinsuranceoptionid
和vehicle.VEHICLERENTALCATEGORYID=VEHICLERENTALCATEGORYID
分组
客户ID
订购人
应付账款总额;

这取决于您想对
天值执行什么操作。一个小的表别名会起很大作用。如您所见,customerid=1有两个结果。我想把它们合并成一行。非常感谢。成功了!!