[英]“not a single-group group function”
Hi I am trying to get the below logic working. 嗨,我正在尝试使以下逻辑正常工作。 but it says Not a single-group by function.. not sure why..I want to get records that are in both table and add the revenue of each to accumulate total revenue in the first select.
但它说不是按功能分组。.不知道为什么..我想获取两个表中的记录,然后将每个表的收入相加以在第一选择中累计总收入。
select ob_location_id,
ib_location_id,
vehicle_class,
return_date,
RENTAL_DATE,
sum(revenue) as TotalRevenue
from
(select ob_location_id,
ib_location_id,
vehicle_class,
return_date,
RENTAL_DATE,
SUM(DEMAND_TO_COME * BOARD_RATE) AS revenue
from PA_FCS_BLEND_FINAL) a
Union all
Select
ob_location_id,
ib_location_id,
vehicle_class,
return_date,
RENTAL_DATE,
sum(MATERIALIZED_BOH_REVENUE) as revenue
from PA_FCS_BLEND_BOH
group by
ob_location_id,
ib_location_id,
vehicle_class,
return_date,
RENTAL_DATE,
totalRevenue;
a
inline view is missing the GROUP BY
clause a
内嵌视图缺少GROUP BY
子句 GROUP BY
shouldn't contain TOTAL_REVENUE
GROUP BY
不应包含TOTAL_REVENUE
A dummy example (datetypes certainly don't match, but never mind that): 一个虚拟的示例(日期类型当然不匹配,但是请不要介意):
SQL> CREATE TABLE pa_fcs_blend_final
2 (
3 ob_location_id NUMBER,
4 ib_location_id NUMBER,
5 vehicle_class NUMBER,
6 return_date NUMBER,
7 rental_date NUMBER,
8 demand_to_come NUMBER,
9 board_rate NUMBER
10 );
Table created.
SQL> insert into pa_fcs_blend_final values
2 (1, 2, 3, 4, 5, 6, 7);
1 row created.
SQL> CREATE TABLE pa_fcs_blend_boh
2 (
3 ob_location_id NUMBER,
4 ib_location_id NUMBER,
5 vehicle_class NUMBER,
6 return_date NUMBER,
7 rental_date NUMBER,
8 materialized_boh_revenue NUMBER
9 );
Table created.
SQL> insert into pa_fcs_blend_boh values
2 (1, 2, 3, 4, 5, 6);
1 row created.
Query which returns something ; 查询返回什么 ; is it correct?
这是正确的吗? No idea.
不知道。
SQL> SELECT ob_location_id,
2 ib_location_id,
3 vehicle_class,
4 return_date,
5 rental_date,
6 SUM (revenue) AS totalrevenue
7 FROM ( SELECT ob_location_id,
8 ib_location_id,
9 vehicle_class,
10 return_date,
11 rental_date,
12 SUM (demand_to_come * board_rate) AS revenue
13 FROM pa_fcs_blend_final
14 GROUP BY ob_location_id, --> this is missing
15 ib_location_id,
16 vehicle_class,
17 return_date,
18 rental_date) a
19 GROUP BY ob_location_id,
20 ib_location_id,
21 vehicle_class,
22 return_date,
23 rental_date
24 UNION ALL
25 SELECT ob_location_id,
26 ib_location_id,
27 vehicle_class,
28 return_date,
29 rental_date,
30 SUM (materialized_boh_revenue) AS revenue
31 FROM pa_fcs_blend_boh
32 GROUP BY ob_location_id,
33 ib_location_id,
34 vehicle_class,
35 return_date,
36 rental_date --> total_revenue (you had) shouldn't be here
37 /
OB_LOCATION_ID IB_LOCATION_ID VEHICLE_CLASS RETURN_DATE RENTAL_DATE TOTALREVENUE
-------------- -------------- ------------- ----------- ----------- ------------
1 2 3 4 5 42
1 2 3 4 5 6
SQL>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.