oracle sql报表统计,怎么按订单类别,分组显示订单总数和交易成功订单数。
4个回答
展开全部
SELECT
ord.ORDER_TYPE as 订单类型,
COUNT(ord.ORDER_ID) as 订单总数,
orde.succCount as 交易成功订单总数
FROM
ORDER ord
LEFT JOIN
(
SELECT
ORDER_TYPE,
COUNT(ORDER_ID) AS succCount
FROM
ORDER
WHERE
STATUS_ID = 'ORDER_SUCCESS'
GROUP BY
ORDER_TYPE
)
orde
ON
orde.ORDER_TYPE = ord.ORDER_TYPE
GROUP BY
ord.ORDER_TYPE;
还有一种方法是,
SELECT
ORDER_TYPE AS 订单类型,
STATUS_ID AS 订单状态,
COUNT(ORDER_ID) AS 订单数
FROM
ORDER
GROUP BY
ORDER_TYPE,
STATUS_ID;
查出以订单类型的不同状态为分组的订单数,然后在代码中求订单总数
ord.ORDER_TYPE as 订单类型,
COUNT(ord.ORDER_ID) as 订单总数,
orde.succCount as 交易成功订单总数
FROM
ORDER ord
LEFT JOIN
(
SELECT
ORDER_TYPE,
COUNT(ORDER_ID) AS succCount
FROM
ORDER
WHERE
STATUS_ID = 'ORDER_SUCCESS'
GROUP BY
ORDER_TYPE
)
orde
ON
orde.ORDER_TYPE = ord.ORDER_TYPE
GROUP BY
ord.ORDER_TYPE;
还有一种方法是,
SELECT
ORDER_TYPE AS 订单类型,
STATUS_ID AS 订单状态,
COUNT(ORDER_ID) AS 订单数
FROM
ORDER
GROUP BY
ORDER_TYPE,
STATUS_ID;
查出以订单类型的不同状态为分组的订单数,然后在代码中求订单总数
展开全部
select
订单类型,sum(订单数),sum(交易成功订单数) from table_name group by 订单类型
订单类型,sum(订单数),sum(交易成功订单数) from table_name group by 订单类型
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
表order 类型type 总数sum 交易成功数amount
select type,count(sum),count(amount) from order group by type;
select type,count(sum),count(amount) from order group by type;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select a.订单类型, sum(a.交易成功订单总数) from table a group by a.订单类型
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询